Author Topic: Can't build in Code::Blocks, but can build from command line.  (Read 8468 times)

Offline rich_sposato

  • Single posting newcomer
  • *
  • Posts: 4
Can't build in Code::Blocks, but can build from command line.
« 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!

Offline ptDev

  • Almost regular
  • **
  • Posts: 222
Re: Can't build in Code::Blocks, but can build from command line.
« Reply #1 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Can't build in Code::Blocks, but can build from command line.
« Reply #2 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7790
    • My Best Post
Re: Can't build in Code::Blocks, but can build from command line.
« Reply #3 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.
« Last Edit: September 07, 2010, 07:12:53 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline rich_sposato

  • Single posting newcomer
  • *
  • Posts: 4
Re: Can't build in Code::Blocks, but can build from command line.
« Reply #4 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.

Offline rich_sposato

  • Single posting newcomer
  • *
  • Posts: 4
Re: Can't build in Code::Blocks, but can build from command line.
« Reply #5 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