Difference between revisions of "FAQ"

From CodeBlocks
Jump to: navigation, search
(Q: How do I use both Debug and Release builds of wx libraries?)
Line 152: Line 152:
Remember, the CodeBlocks globle variable WX needs to point to the wxWidgets folder.
Remember, the CodeBlocks globel variable WX needs to point to the wxWidgets folder.
Example minGW build command for "Unicode debug" 2.8.0 RC3
Example minGW build command for "Unicode debug" 2.8.0 RC3
Line 165: Line 165:
Contributed by Tim S
Contributed by Tim S
*I have never got the following command to work
*I have never gotten the following command to work
   mingw32-make -f makefile.gcc VENDOR=rc3 CFG=rc3 USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=debug  UNICODE=1
   mingw32-make -f makefile.gcc VENDOR=rc3 CFG=rc3 USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=debug  UNICODE=1

Revision as of 16:31, 7 December 2006


Q: Is it possible to integrate the win32-help as in dev-cpp, to get help on the items under the caret?

A: Integration of the Win32 API helpfile should be a no-brainer. Someone could just write a really simple plugin and, upon invocation (through a shortcut possibly), look at the word under the cursor and invoke windows help... If you think you 're up to the task, I can help you with all the info you need. If not, I could write it myself but no promises on a release date ;)

Q: What licence is Code::Blocks released under?

A: GNU General Public License 2 (GPL)


Q: What compiler can I use with Code::Blocks?

A: Code::Blocks philosophy is to be able to use any compiler on earth! Well, almost.

As a matter of fact it largely depends on the used compiler plugin. The one provided with the default Code::Blocks installation, supports GNU GCC (MinGW/Cygwin), MS Visual C++ Free Toolkit 2003, Borland's C++ Compiler 5.5, DigitalMars Free Compiler., OpenWatcom and Small Device C Compiler (SDCC).

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: My project should be compiled with a custom makefile. Is it possible with Code::Blocks?

A: Yes, you can. You need to change two different settings:

a) In "Compiler Settings", under the tab "Other", there's a setting called "Build Method". Choose "Work with makefiles".

b) In your project's Properties, you can choose to use a makefile. Check "This is a custom makefile" (WARNING! if you forget to check, the makefile will be OVERWRITTEN!)

And that's it! :)

Q: I have downloaded MS VC++ Toolkit 2003 for a compiler. How do I tell Code::Blocks that it is my compiler?

A: Click on "Project/Build options" and select the compiler you want for your project/target.

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 are coming 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)

C++ libs:

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.

See also: tclsh script to extract import .lib from (any?) DLL (MinGW)

See also: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_c_run.2d.time_libraries.asp

See also: http://sapdb.2scale.net/moin.cgi/MS_20C_2b_2b_20Toolkit

Q: Microsoft calls MSVCRT.DLL a "Known DLL." How do I know if I can/should use it ?

Microsoft does not clearly describe what 'Known DLL' means. A zLib FAQ entry makes it much more clear. The short answer is that MSVCRT.DLL is a protected system component and to preserve system integrity it cannot be updated by any end user product installers but may be updated from time to time by system updates. If it works use it. If it doesn't you'll need use a non protected library such as MSVCR70 or MSVCR80 which not only can be updated but private versions can be installed. A small and simple C program is likely to work just fine with MSVCRT.DLL. A large and complex C++ program is more likely to need the additional functionality of MSVCR.

The MSVCRT.LIB that ships with Visual C++ Toolkit 2003 dynamically links to MSVCR71.DLL which is not present in a freshly installed Windows XP system. MSVCR only appears after some software package that needs it such as Adobe Acrobat Reader is installed. This means that programs that depend on MSVCR must redistribute it or risk not working on a substantial percentage of systems for reasons not obvious to either the affected end users or the program supplier. For projects that can safely use MSVCRT and where it is impractical to redistribute MSVCR, a MSVCRT.LIB that links to MSVCRT.DLL is available in any Device Driver Kit. It is best to preserve the MSVCRT.LIB provided by the compiler and alter the name of the MSVCRT.LIB extracted from a DDK. List your newly named MSVCRTxx in the libs and to prevent problems it is recommended to include both /MD and /NODEFAULTLIB:MSVCRT switches so that problems come up at link time instead of random crashes at run time. Be sure to load your programs into Dependancy Walker to ensure that functions aren't being linked into MSVCRxx.DLL and MSVCRT.DLL. It is essential that malloc, calloc, realloc, free, and related memory allocation functions all import from the same DLL. If you use MSVCRT.LIB from the Windows 2003 DDK you may encounter the link error LNK2001: unresolved external symbol ___security_cookie. This can be solved by switching to the MSVCRT.LIB in the Windows XP DDK or by linking bufferoverflowU.lib found in the Windows SDK.

Source: TCL Wiki

Q: How can I use a DLL without DEF or LIB files ?

A: I tried to find a solution, and the following script solved the problem for me. I used a cygwin environment for tclsh and sed, but the MinGW tools for objdump and dlltool. See here tclsh script to extract import .lib from (any?) DLL (MinGW)

TODO: Someone might add some informations about problems

Request: Is MinGW or Code::Blocks able to support automatic generation of import libraries ?

See also: http://www.mingw.org/mingwfaq.shtml#faq-msvcdll

See also: http://wyw.dcweb.cn/stdcall.htm

Q: Where are the libraries for the OpenGL, Ogre3D, SDL, QT, wxWidgets etc. projects?

A: They're not bundled. The templates were provided for your convenience, but you need to download the libraries on your own. In common terms, "batteries not included" :)

Q: Is it possible to use Visual C++ 6.0 with Code::Blocks?

A: Yes. See Integrating Microsoft Visual C 6 with Code::Blocks IDE for a detailed description on using VC++ 6.0 with Code::Blocks.

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: I would like to compile a project using some non-standard libraries. How can I indicate to CodeBlocks that these libraries and include files exist?

A: You can specify them for your global environment or just for your project.

For global environment :
- Menu Settings/Compiler and debugger
- In the Global compiler settings, select the directories tab
- Add the required paths for compiler and linker.

For your project :
- Right click on the project then select Build options
- Select the directories tab
- Add the required paths for compiler and linker.
- Add your specific libraries in the linker tab.
- Pay attention to project settings and target settings.

Q: How do I use both Debug and Release builds of wx libraries?

A: I would use the default method of doing it and the default folder naming.

Using these C::B custom varibles

WX_SUFFIX=""  // ANSI Release
WX_SUFFIX="d"  // ANSI Debug
WX_SUFFIX="u"  // Unicode Release
WX_SUFFIX="ud"  // Unicode debug

I use WX_CFG when I am using a special configuration WX_CFG="rc3"

Remember, the CodeBlocks globel variable WX needs to point to the wxWidgets folder.

Example minGW build command for "Unicode debug" 2.8.0 RC3

mingw32-make -f makefile.gcc VENDOR=rc3 CFG=rc3 USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=debug   UNICODE=1

"VENDOR=" just puts rc3 in the DLL name; "CFG=" sets which folder the DLL is placed in. In this case in lib\gcc_dllrc3

Before using CFG in the mingw32-make build you need to do one prior wxWidget build without using it; else the build errors out.

"__WXDEBUG__" must be defined (in the codeblocks project setting) if you wish to link against the debug version of wxWidgets DLL. Else you will get a runtime error, when you try to run your project output.

Contributed by Tim S


  • I have never gotten the following command to work
 mingw32-make -f makefile.gcc VENDOR=rc3 CFG=rc3 USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=debug   UNICODE=1
  • unless I have first run this command on the same wxWidgets folders
 mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=debug   UNICODE=1
  • I am guessing that the build without the CFG creates a file or directory needed by the build with the CFG.


Q: How do I get Code Completion to work?

A: Did you check how code completion is configured ? See "Settings/Editor", click on "Code-completion and symbols browser" in the left column and check the Code completion and C/C++ parser tabs.

From the 2006/11/30 nightly build, you can also add, in the project properties, directories to be searched when locating a file to parse .Right click on the project, click on Properties and select the C/C++ parser options.

They 're mostly useful when you don't add compiler search dirs in build options but use backticked expressions (e.g. `freetype-config --cflags`). In this case, the parser is not aware of where the source files are located. So, by manually adding the directory in the parser's search dirs you 're actually helping the parser find the files.

Of course, backticked expressions are not the only reason these parser search dirs are useful. As another example, I have a set of projects in a workspace. To minimize maintenance overhead, I 'm using build scripts to configure these projects. Now, although build scripts are an awesome feature, the C/C++ parser faces the same problem: it doesn't know where to search for files. The parser search directories come to the rescue again.