Difference between revisions of "Common problems and solutions"

From Code::Blocks
m (→‎Solution: Remark that codeblocks.RPT may be in the config directory)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
[[Category:Deletion Requests]]
 +
[[Category:User Documentation]]
 +
''All content has been moved to the [[FAQ]].''
 +
 
This page contains many of the common problems Code::Blocks users may run into and their solutions.
 
This page contains many of the common problems Code::Blocks users may run into and their solutions.
  
Line 7: Line 11:
  
 
===Solution===
 
===Solution===
Code::Blocks can only use integrated debugging on an active project.  Start a [[Creating a new project|new project]] and [[Creating a new project#Adding a pre-existing file|add the file]] to it.
+
Code::Blocks can only use integrated debugging on an active project.  Start a [[Creating a new project|new project]] and [[Creating a new project#Adding a pre-existing file|add the file]] to it. Also see [[debugging with Code::Blocks]].
  
 
''Note: Code:Blocks only supports the GNU GDB and MSVC CDB debuggers.''
 
''Note: Code:Blocks only supports the GNU GDB and MSVC CDB debuggers.''
Line 19: Line 23:
  
 
===Solution===
 
===Solution===
Open ''Project->Properties...->Build targets (tab)'' and select the executable.  Click ''Dependencies...'' and add the name of the library (including its relative path) to ''External dependency files''.
+
Open ''Project->Properties...->Build targets (tab)'' and select the executable.  Click ''Dependencies...'' and add the name of the library (including its relative path) to ''External dependency files''. Also see [[The build process of Code::Blocks#Using project dependencies|inter-project dependencies]].
  
 
''Example:'' <tt>output\myLibrary\libdostuff.a</tt>
 
''Example:'' <tt>output\myLibrary\libdostuff.a</tt>
Line 31: Line 35:
 
Try building the project from command line. If the same error comes up, it is a problem with either the source file, the compiler, or the compiler setup. If this is the case, you are unlikely to receive support for it on the Code::Blocks forums, however, [[FAQ#Q: How do I troubleshoot an compiler problem?|How do I troubleshoot an compiler problem?]] may help.
 
Try building the project from command line. If the same error comes up, it is a problem with either the source file, the compiler, or the compiler setup. If this is the case, you are unlikely to receive support for it on the Code::Blocks forums, however, [[FAQ#Q: How do I troubleshoot an compiler problem?|How do I troubleshoot an compiler problem?]] may help.
  
If it works fine building from command line, it is either a problem with your project or Code::Blocks' setup, or possibly an actual bug. When posting this problem, include the name of your compiler, operating system, Code::Blocks version, compiler log (go to ''Settings->Compiler and debugger...->Build options (tab)'' and check ''Save build log'' and ''Always output the full command line''), and, if it caused Code::Blocks to crash, the <tt>codeblocks.RPT</tt> file (located in the Code::Blocks installation directory).
+
If it works fine building from command line, it is either a problem with your project, Code::Blocks' setup, or possibly an actual bug. When posting this problem, include the name of your compiler, operating system, Code::Blocks version, compiler log (go to ''Settings->Compiler and debugger...->Build options (tab)'' and check ''Save build log'' and ''Always output the full command line''), and, if it caused Code::Blocks to crash, the <tt>codeblocks.RPT</tt> file (located in the Code::Blocks installation directory if it is writable or in the config directory if it is not).
  
 
''Template: Paste the following template into your post, editing the relevant sections.''
 
''Template: Paste the following template into your post, editing the relevant sections.''
Line 53: Line 57:
  
 
===Problem===
 
===Problem===
All of the '''Build''' related options are grayed out.
+
All of the ''Build'' related options are grayed out.
  
 
===Solution===
 
===Solution===
Line 83: Line 87:
 
===Solution===
 
===Solution===
 
Some parts of Code::Blocks or the back-end compiler may not support non ASCII characters (such as é) or possibly spaces. Try moving the project on the affected computer to a directory that contains neither of these in its path.
 
Some parts of Code::Blocks or the back-end compiler may not support non ASCII characters (such as é) or possibly spaces. Try moving the project on the affected computer to a directory that contains neither of these in its path.
 +
 +
==Help, no one can solve my problem==
 +
 +
===Problem===
 +
I posted on the forums that Code::Blocks was not working, but no one could help me.
 +
 +
===Solution===
 +
There is a distinct lack of crystal balls and divining mirrors here, so you may want to post some information. Using this [[#I want to report compile problem abc|template]] in your problem description would be a great help.
 +
 +
==Multiple ''undefined reference'' errors==
 +
 +
===Problem===
 +
Every time I build, Code::Blocks reports multiple <tt>undefined reference</tt> errors.
 +
 +
''Example:''
 +
undefined reference to `WSACleanup@8
 +
undefined reference to `WSACleanup@0
 +
 +
===Solution===
 +
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.

Latest revision as of 12:17, 11 April 2022

All content has been moved to the FAQ.

This page contains many of the common problems Code::Blocks users may run into and their solutions.

I cannot use the debugger

Problem

All the options in the debug menu are grayed out.

Solution

Code::Blocks can only use integrated debugging on an active project. Start a new project and add the file to it. Also see debugging with Code::Blocks.

Note: Code:Blocks only supports the GNU GDB and MSVC CDB debuggers.

Multi-targets library and executable ignore interdependence

Problem

My project contains a two targets: static/dynamic library and an executable that links to it. Code::Blocks does not

  • build the library first.
  • force relink if the library is changed.

Solution

Open Project->Properties...->Build targets (tab) and select the executable. Click Dependencies... and add the name of the library (including its relative path) to External dependency files. Also see inter-project dependencies.

Example: output\myLibrary\libdostuff.a

I want to report compile problem abc

Problem

Every time I build my project xyz, compile problem abc happens, and I want to report it on the forums as a Code::Blocks bug.

Solution

Try building the project from command line. If the same error comes up, it is a problem with either the source file, the compiler, or the compiler setup. If this is the case, you are unlikely to receive support for it on the Code::Blocks forums, however, How do I troubleshoot an compiler problem? may help.

If it works fine building from command line, it is either a problem with your project, Code::Blocks' setup, or possibly an actual bug. When posting this problem, include the name of your compiler, operating system, Code::Blocks version, compiler log (go to Settings->Compiler and debugger...->Build options (tab) and check Save build log and Always output the full command line), and, if it caused Code::Blocks to crash, the codeblocks.RPT file (located in the Code::Blocks installation directory if it is writable or in the config directory if it is not).

Template: Paste the following template into your post, editing the relevant sections.

OS = MyOperatingSystem
CB Version = Code::BlocksVersionNumber
Compiler = CompilerName CompilerVersionNumber

Description of relevant events.

Build log:
[code]
Paste build log here
[/code]

Crash report:
[code]
If Code::Blocks crashed, paste the contents of codeblocks.RPT here.
[/code]

I cannot build my project

Problem

All of the Build related options are grayed out.

Solution

Code::Blocks checks the file extension for individual files before allowing them to be compiled. Save your file with the correct file extension (*.c or *.cpp).

More often it is useful to create a project so that Code::Blocks can manage the entire build

Code::Blocks option xyz is missing

Problem

The useful feature xyz I was told to use is nowhere to be found in Code::Blocks.

Solution

Many features of Code::Blocks are implemented by means of plugins. First open Plugins->Manage plugins... and ensure that the one you are trying to use is not disabled. If plugin xyz is not in the list, it is possible that you removed/disabled it on installation. To acquire the plugin, reinstall Code::Blocks (double checking that the desired plugin is included).

Syntax highlighting is broken

Problem

I am typing valid code, but it is all appearing as black text.

Solution

Code::Blocks cannot know how to highlight your code unless it knows what lexer to use. This is normally automatically determined by the file extension, so it is important to save the file and name it correctly (*.c or *.cpp for C and C++ code). It is also possible to activate syntax highlighting on a temporary basis. Open Edit->Highlight mode and select the language the current file is using.

Untraceable reoccurring error

Problem

Project abc works everywhere except one computer where it gets stuck on step xyz.

Solution

Some parts of Code::Blocks or the back-end compiler may not support non ASCII characters (such as é) or possibly spaces. Try moving the project on the affected computer to a directory that contains neither of these in its path.

Help, no one can solve my problem

Problem

I posted on the forums that Code::Blocks was not working, but no one could help me.

Solution

There is a distinct lack of crystal balls and divining mirrors here, so you may want to post some information. Using this template in your problem description would be a great help.

Multiple undefined reference errors

Problem

Every time I build, Code::Blocks reports multiple undefined reference errors.

Example:

undefined reference to `WSACleanup@8
undefined reference to `WSACleanup@0

Solution

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.