1. File path for header files(找不到头文件)
project -> build options ->search directories -> (compiler or linker)
note that you can set directories to be project or target specific (manage your targets in project -> properties)
you can also declare global variables that reside in your user settings, so that you don't have to hardcode paths in your project files.
see also:
http://wiki.codeblocks.org/index.php?title=The_build_process_of_Code::Blocks
http://wiki.codeblocks.org/index.php?title=Global_compiler_variables
http://wiki.codeblocks.org/index.php?title=Builtin_variables
2. 使用Code::Blocks编译socket代码需要增加ws2_32.lib文件
在链接库中间增加如下路径,
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\ws2_32.lib"
连双引号都需要复制进去,否则会因为路径中间有空格报路径错误;
Code Blocks v12.11 添加方法如下:
==========================================
Settings --> Compiler --> Search directories --> Linker --> Add 按钮
==========================================
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\
无需引号;
(注意:
1. v6.0A 根据你电脑上的版本而定。
2. 64位的windows C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\ 可能在Program Files (x86)下。
3. 如果以上方法不行,直接将如下连个lib文件,拷贝到工程目录下。
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\WS2_32.LIB
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\WSOCK32.LIB
之后添加下,即可。
4. 如上方法大部分都能解决,如果有的还解决不了,根据需要添加
使用Code::Blocks写Socket Program的设定
Settings -> Compiler -> Linker Settings -> Other linker options -> 加上-lws2_32
)