Code::Blocks Forums

User forums => Help => Topic started by: thor36 on December 08, 2015, 01:50:25 pm

Title: Problem setting up new compiler
Post by: thor36 on December 08, 2015, 01:50:25 pm
Greetings,

I downloaded mingw 5.2 compiler that comes with MSYS2 package (Win 7, 64 bit). Then I tried to set up new compiler in settings -> compiler -> toolchain executables in Code Blocks, by altering compiler's installation directory and program paths.

When I tried to build an application I got various errors, some about 3rd party library I used and some about standard library, like this one:
main.cpp|42|undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'|

So I assume I made mistakes when setting up compiler in the settings (I also ticked C++11 support in build options). Can someone help identify what I did wrong? My settings are like this:

compiler's installation directory:
C:\msys64\mingw32\bin

C compiler:
i686-w64-mingw32-gcc-5.2.0.exe

C++ compiler:
i686-w64-mingw32-g++.exe

Linker for dynamic libs:
i686-w64-mingw32-g++.exe

Linker for static libs:
i686-w64-mingw32-gcc-ar.exe

Resource compiler:
windres.exe

Make program:
/ (can't see ming32-make in bin folder)

Thank you,
T
Title: Re: Problem setting up new compiler
Post by: cacb on December 08, 2015, 03:54:30 pm
Greetings,

I downloaded mingw 5.2 compiler that comes with MSYS2 package (Win 7, 64 bit). Then I tried to set up new compiler in settings -> compiler -> toolchain executables in Code Blocks, by altering compiler's installation directory and program paths.

When I tried to build an application I got various errors, some about 3rd party library I used and some about standard library, like this one:
main.cpp|42|undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'|

Hi,
I don't use that compiler, but for the standard library stuff (that comes with the toolchain), I think you need to add proper compiler and linker search directories under.

Global compiler Settings -> Search directories -> Compiler/Linker

For 3rd party libraries it is best to do it under each project: Build Options
Title: Re: Problem setting up new compiler
Post by: thor36 on December 08, 2015, 04:59:03 pm
You are right cacb, this was exactly the problem, thank you very much. Previously I used MinGW bundled with CB and it did the work automatically. Correct settings (that seem to work at least for my test project) are:

Compiler:
C:\msys64\mingw32\i686-w64-mingw32\include

Linker:
C:\msys64\mingw32\i686-w64-mingw32\lib
Title: Re: Problem setting up new compiler
Post by: oBFusCATed on December 08, 2015, 08:41:22 pm
This should work automatically, the compiler should know where the bits for the standard library are.
So either it is broken or your installation is broken.

To verify it try it on the command line.
Title: Re: Problem setting up new compiler
Post by: thor36 on December 08, 2015, 10:05:33 pm
This should work automatically, the compiler should know where the bits for the standard library are.
So either it is broken or your installation is broken.

To verify it try it on the command line.

Sorry, I  don't know how to verify it on the command line, can you please explain that?
Title: Re: Problem setting up new compiler
Post by: oBFusCATed on December 09, 2015, 01:31:57 am
Just run g++ main.cpp (you have to use proper paths for g++ and main.cpp).
If this doesn't work, check out the manual or support forum for your compiler.
Title: Re: Problem setting up new compiler
Post by: stahta01 on December 09, 2015, 01:50:00 am
Greetings,

I downloaded mingw 5.2 compiler that comes with MSYS2 package (Win 7, 64 bit). Then I tried to set up new compiler in settings -> compiler -> toolchain executables in Code Blocks, by altering compiler's installation directory and program paths.

When I tried to build an application I got various errors, some about 3rd party library I used and some about standard library, like this one:
main.cpp|42|undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'|

So I assume I made mistakes when setting up compiler in the settings (I also ticked C++11 support in build options). Can someone help identify what I did wrong? My settings are like this:

compiler's installation directory:
C:\msys64\mingw32\bin

This is likely wrong.
Likely need "C:\msys64\mingw32"

C compiler:
i686-w64-mingw32-gcc-5.2.0.exe

C++ compiler:
i686-w64-mingw32-g++.exe

Linker for dynamic libs:
i686-w64-mingw32-g++.exe

Linker for static libs:
i686-w64-mingw32-gcc-ar.exe

This may be wrong I use "ar.exe"

Resource compiler:
windres.exe

Make program:
/ (can't see ming32-make in bin folder)

Thank you,
T

I also edited "Cygwin GCC" compiler instead of the "GNU GCC Compiler".

Edit: Please read and follow this FAQ if you still need help!
http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)

Tim S.


Title: Re: Problem setting up new compiler
Post by: stahta01 on December 09, 2015, 01:56:45 am
FYI:

Adding the compiler search folders is NOT needed for MSYS2; and, if you do add paths for 3rd party libs/header use a forward slash!

MSYS2 does NOT like "\" backslashes in paths passed to the compiler.

Edit: The type of third party libs makes a difference in how to fix the errors.
1. Self-Compiled third party libs
2. MSys2 third party MinGW libs (I am working on a custom built Code::Blocks to make this easier to do.)
3. third party libs downloaded as binary libs. (This is NOT likely to work unless the libraries are C libraries!)

Tim S.

Greetings,

I downloaded mingw 5.2 compiler that comes with MSYS2 package (Win 7, 64 bit). Then I tried to set up new compiler in settings -> compiler -> toolchain executables in Code Blocks, by altering compiler's installation directory and program paths.

When I tried to build an application I got various errors, some about 3rd party library I used and some about standard library, like this one:
main.cpp|42|undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'|

Hi,
I don't use that compiler, but for the standard library stuff (that comes with the toolchain), I think you need to add proper compiler and linker search directories under.

Global compiler Settings -> Search directories -> Compiler/Linker

For 3rd party libraries it is best to do it under each project: Build Options
Title: Re: Problem setting up new compiler
Post by: MortenMacFly on December 09, 2015, 08:35:02 pm
When I tried to build an application I got various errors, some about 3rd party library I used and some about standard library, like this one:
main.cpp|42|undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'|
First of all: This is not a Code::Blocks issue.

However, it seems parts of your code are compiled with C++11. Therefore, try to specify/anable -std=c++11 as compiler option.

Once again: This forum is not for discussing compiler issues. We assume you know what SDK you use and what the requirements are.
Title: Re: Problem setting up new compiler
Post by: thor36 on December 10, 2015, 12:44:05 pm
Ok, thank you all for help.
Alright it is a compiler issue not a Code::Blocks issue I suppose. But it's nice to get support from a community that uses same IDE. Surely it is easier to find someone who can relate to the problem you have (even uses same tools) and can give more specific advice.
Is a new sub-forum for such issues an option?
I am totally aware that core C::B dev team is too busy to deal with such issues, but this community seems large enough to accomodate this. I would even argue that long term impact would be more people moving to C::B.
Anyway, thanks and keep up the great work with C::B and the forums!
Title: Re: Problem setting up new compiler
Post by: stahta01 on December 10, 2015, 03:14:00 pm
FYI:

If you still need help with the compiler I suggest here http://cboard.cprogramming.com/windows-programming/ (http://cboard.cprogramming.com/windows-programming/)

And, I may have failed to communicate MSYS2 is closest to the Windows CygWin Compiler!!!

So, you need to use "CygWin Compiler" or edit the GCC Compiler advanced options to use forward slash in Code::Blocks compiler settings.

Tim S.

Title: Re: Problem setting up new compiler
Post by: MortenMacFly on December 10, 2015, 05:48:50 pm
Is a new sub-forum for such issues an option?
No, because we (the few admins) need to read every single post by law. So if we open the forum to non-C::B topics than this will keep us (admins/devs) busy. Please understand that we are rather strict on that topic (btw, as also explained in the forum rules you agreed to when registering here).

However, if you open a forum dedicated to such topics we would happily provide a link here to that forum as long as we don't need to administrate the "other forum". That would be your duty then... unless you live and host the server in a country where this doesn't matter.
Title: Re: Problem setting up new compiler
Post by: thor36 on December 10, 2015, 09:08:10 pm
@stahta01
Thank you for the link! I must say I was looking for best place to ask some MinGW, compilation, makefiles... related questions. But I am so new to this that I honestly don't even know how to ask for the right place, or how to know what's the right place (obviously there is no "MinGW forum" or "C++ compilation process forum" :D So actually any further advice would be most welcome.

@MortenMacFly
I understand, what I was saying wasn't a complaint, just my thoughts. I'm sure work on the IDE itself takes enough time already, so you all running this forum alongside is extra appreciated.
Title: Re: Problem setting up new compiler
Post by: Pecan on December 11, 2015, 05:15:58 pm
Google "mingw forum" and "C++ forum" for some good locations. I've used and appreciated the top results.