Code::Blocks Forums

User forums => Help => Topic started by: rich_sposato on September 07, 2010, 08:54:19 am

Title: Can't build in Code::Blocks, but can build from command line.
Post by: rich_sposato on September 07, 2010, 08:54:19 am
I get this error message when I try to build a C++ project on Code::Blocks.

Execution of 'g++-4.exe  -W -g  -Weffc++   -I. -I./include -c E:/Projects/BlueSpot/src/BlueSpot.cpp -o obj/Debug/src/BlueSpot.o'  in 'E:\Projects\BlueSpot' failed.

Code::Blocks version 10.5
Operating System: Windows XP

When I try the identical command line on cygwin, the file compiles without error.  There are no unusual characters or spaces in the paths or filenames.

If I try the same command from a DOS prompt, I get this error message: "/usr/lib/gcc/i686-pc-cygwin/4.3.4/cc1plus.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory".

Can anybody solve this one for me?

Thanks!
Title: Re: Can't build in Code::Blocks, but can build from command line.
Post by: ptDev on September 07, 2010, 09:48:52 am
cygwin emulates a unix-like system under windows, so a command that runs in cygwin should not run in a DOS prompt most of the time.

I don't think cygwin is even correctly supported by Code::Blocks. I do know that MinGW (a port of GCC to native Windows binaries) should work properly.
Title: Re: Can't build in Code::Blocks, but can build from command line.
Post by: MortenMacFly on September 07, 2010, 10:03:20 am
I don't think cygwin is even correctly supported by Code::Blocks.
Cygwin is supported just fine. However, you should choose this as compiler for your project and not use a MinGW based one.
Title: Re: Can't build in Code::Blocks, but can build from command line.
Post by: stahta01 on September 07, 2010, 03:43:53 pm
Have you verified the existence of "cc1plus.exe" in folder CygWin\lib\gcc\i686-pc-cygwin\4.3.4?

Not sure the above applies after rereading your post.

Things that must be done to really test/use multiple GCC installations under windows.
Verify that NO gcc installations are in your system path.
Verify that x:\mingw does not exist for any value of "X"

Open an cmd prompt window.
change directory to folder holding CB project file.
set path to have the Compiler Bin folder first in the list

Try to execution the command used by CB under full compiler logging here.

I did it below and did not get error.
Code
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

D:\Users\stahta01>cd /d H:\SourceCode\CBProjects\TestProjects\testcyg

H:\SourceCode\CBProjects\TestProjects\testcyg>set PATH=D:\GreenApps\CygWin\bin;%PATH%

H:\SourceCode\CBProjects\TestProjects\testcyg>g++-4.exe -Weffc++ -Wall  -g -W -I../testcyg -IH:/SourceCode/CBProjects/TestProjects/testcyg -IH:/SourceCode/CBProjects/TestProjects/testcyg -c H:/SourceCode/CBProjects/TestProjects/testcyg/main.cpp -o obj/Debug/main.o

Tim S.
Title: Re: Can't build in Code::Blocks, but can build from command line.
Post by: rich_sposato on September 07, 2010, 07:10:50 pm
Cygwin is supported just fine. However, you should choose this as compiler for your project and not use a MinGW based one.

Yes, I much prefer the gcc version that comes with cygwin over the one provided with MinGW.
Title: Re: Can't build in Code::Blocks, but can build from command line.
Post by: rich_sposato on September 07, 2010, 07:28:50 pm
Have you verified the existence of "cc1plus.exe" in folder CygWin\lib\gcc\i686-pc-cygwin\4.3.4?

Not sure the above applies after rereading your post.

Things that must be done to really test/use multiple GCC installations under windows.
Verify that NO gcc installations are in your system path.
Verify that x:\mingw does not exist for any value of "X"

Open an cmd prompt window.
change directory to folder holding CB project file.
set path to have the Compiler Bin folder first in the list

Try to execution the command used by CB under full compiler logging here.

...

Tim S.

Thanks Tim.  Your suggestion worked.  After confirming that changing the PATH variable worked when compiling from a DOS prompt, I then changed the environment variable in Windows settings.  Upon doing that, I restarted Code::Blocks and recompiled the project.  It now compiles without making cryptic error messages.

Yes, the cc1plus.exe is in folder CygWin\lib\gcc\i686-pc-cygwin\4.3.4.  The error message in the original post implies that cc1plus.exe exists and was executed, but can't load a shared object.

Thanks again!

Rich