- 1 Compiling (errors)
- 1.1 Q: I imported a MSVCToolkit project/workspace, but Code::Blocks insists on trying to use GCC. What's wrong?
- 1.2 Q: When compiling a wxWidgets project, I get several "variable 'vtable for xxxx' can't be auto-imported". What's wrong?
- 1.3 Q: I can't compile a multithreaded app with VC Toolkit! Where are the libraries?
- 1.4 Q: I get this error when compiling: Symbol "isascii" was not found in "codeblocks.dll"
- 1.5 Q: How do I troubleshoot an compiler problem?
- 1.6 Q: My build fails with multiple undefined reference errors?
- 1.7 Q: My build fails in the compile/link/run step with a Permission denied error?
Return to FAQ.
Q: I imported a MSVCToolkit project/workspace, but Code::Blocks insists on trying to use GCC. What's wrong?
A: A little documentation problem ^^;. The "default compiler" is usually GCC, so when you imported it with "the default compiler", you told it to use GCC. To fix this situation, go to "Project", "Build Options" and select VC++ Toolkit as your compiler.
Another possibility is to put the Microsoft compiler as the default one. To do this, choose Settings - Compiler, choose the Microsoft compiler in the Selected Compiler section (top of dialog box) and press the Set as default button.
From now onwards, for all new projects the Microsoft compiler will be taken by default.
Q: When compiling a wxWidgets project, I get several "variable 'vtable for xxxx' can't be auto-imported". What's wrong?
A: You need to add WXUSINGDLL in "Project->Build options->Compiler #defines" and rebuild your project (or create a new project and use the "Using wxWidgets DLL" project option which adds "-DWXUSINGDLL" to Project->Build options->Other options). Other errors with the same resolution are: 'unresolved external symbol "char const * const wxEmptyString" ([email protected]@3PBDB)' or similar. If you were using 1.0-finalbeta and were trying to build a statically linked wxWidgets project, the cause of the problem was some faulty templates. But that's fixed now.
Q: I can't compile a multithreaded app with VC Toolkit! Where are the libraries?
A: Sorry, no fix for your problem...
Your problem doesn't come from CodeBlocks. It exists, because the free VC toolkit (VCTK) doesn't provide all the libraries and tools which come with Visual C++ (VC) which isn't free, unfortunately.
Try buying a full-fledged VC++, or even better, download MinGW
The libraries that can be obtained free of charge are:
(VCT3) Visual C++ Toolkit 2003 - C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib (PSDK) Platform SDK - C:\Program Files\Microsoft Platform SDK\Lib (NSDK) .NET 1.1 SDK - C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib
C runtime libs:
LIBC.LIB Single-threaded, static link (VCT3, NSDK) LIBCMT.LIB Multithreaded, static link (VCT3, NSDK) MSVCRT.LIB Multithreaded, dynamic link (import library for MSVCR71.DLL) (NSDK) LIBCD.LIB Single-threaded, static link (debug) (VCT3, NSDK) LIBCMTD.LIB Multithreaded, static link (debug) (NSDK) MSVCRTD.LIB Multithreaded, dynamic link (import library for MSVCR71D.DLL) (debug) (NSDK)
LIBCP.LIB Single-threaded, static link (VCT3, PSDK) LIBCPMT.LIB Multithreaded, static link (VCT3) MSVCPRT.LIB Multithreaded, dynamic link (import library for MSVCP71.dll) (none) LIBCPD.LIB Single-threaded, static link (debug) (VCT3) LIBCPMTD.LIB Multithreaded, static link (debug) (none) MSVCPRTD.LIB Multithreaded, dynamic link (import library for MSVCP71D.DLL) (debug) (none)
Try setting the library linker directories to:
C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib C:\Program Files\Microsoft Platform SDK\Lib C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib
in that order.
The ones listed as (none) above are actually present in the IA64 and AMD64 subdirectories of the PSDK lib directory. Not sure if these would work on 32-bit windows, however, they may if they are meant to work in 32-bit compatibility mode on the 64-bit processors. Worth a try. Otherwise, you can link statically to the C++ library instead of using MSVCP71.dll. If you really want to link against MSVCP71.dll you can try to create MSVCP71.LIB from the dll using lib.exe and sed. Search google for "exports.sed" for detailed steps.
Q: I get this error when compiling: Symbol "isascii" was not found in "codeblocks.dll"
A: Make sure you didn't mix up the MSVC headers or libs with the MinGW ones.
Q: How do I troubleshoot an compiler problem?
A: I would start by turning on full Compiler logging.
This is done by selecting the "Full command line" option Under menu "Settings" -> "Compiler and Debugger" -> Global compiler settings -> [the compiler you use] -> "Other Setting" tab, "Compiler logging".
This option will make Code::Blocks output the exact commands it uses to compile your code.
Things to remember:
- You should review all the commands and their options;
- If you don't know what an option or a command does please read the documentation for the compiler/linker you're using;
- Look for missing commands;
- For every source file (.cpp; .c; .d; etc) in your project, you must have at least one command in the log. This command must produce an object file (file extension .o if using gcc/g++ and .obj if using Visual Studio);
- Every object file should be linked in the final executable, if not there are undefined symbols errors;
- Remember the file extension matters: *.c is compiled as C file, *.cpp is compiled as C++ file. Read more
Q: My build fails with multiple undefined reference errors?
undefined reference to `[email protected] undefined reference to `[email protected]
A: Most of the time it is because the required library is not linked with your project. Go to Project->Build options...->Linker settings (tab) and add the required library or libraries.
If the error includes a line number, it is likely that this is a problem with your code. Track down down your function declarations and implementations. Ensure they all match up, are spelled correctly, and have the correct scope resolution.
A: There are several possible causes for this:
- The output directory does not have read/write access.
- Either change control settings on the output directory, or move the project to different location.
- A previous instance of the executable failed to terminate properly.
- Open your system's equivalent of Process/Task Manager, search the list for the name of the executable Code::Blocks is trying to output, and terminate it.
- Logging off or rebooting will achieve the same effect.
- The executable is open.
- If the executable is open in a hex-editor or actively being run, close it.
- Security software is interfering.
- The target file is locked while an antivirus programming is scanning it; either wait a few seconds for the antivirus scan to finish, set an exception in the antivirus settings, or (temporarily) disable the antivirus program.
- Firewalls with very strict settings sometimes block execution; try reducing the firewall's settings or adding an exception.
- Switching security software may have left traces behind that are interfering; hunt down the remnants of the old antivirus/firewall software and remove them.
- The file/library cannot be found.
- Code::Blocks was improperly installed.
- Mixing binaries from a stable release and a nightly build (or even two different nightly builds) is highly likely to cause a slew of problems; reinstall Code::Blocks in an empty directory.
- Multiple installed compilers are interfering with each other.
- If they are not required to keep, completely remove all but the most used compiler.
- If several compilers are required, ensure that none of them are in the system path (this is so that Code::Blocks will be able to manage all paths).
- Also, do not place any compilers in their default installation path (for example C:\MinGW), as some compilers are hard-coded to look for headers in a default path before searching their own respective directories.