Author Topic: Cannot compile on Linux  (Read 6793 times)

Offline FSM

  • Single posting newcomer
  • *
  • Posts: 3
Cannot compile on Linux
« on: March 04, 2012, 03:28:52 pm »
Hello, I am new to the forum, but I was using Code::Blocks for some time now. I really love it, and I had no major problems that I couldn't solve before. I was using it on Windows with MinGW, but recently I switched to Ubuntu. I think I was able to compile on Ubuntu before, but now when I try to compile anything I get this errors:
-------------- Build: Debug in test ---------------

Compiling: main.cpp
g++: error: to: No such file or directory
g++: error: LDFLAGS: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

I tried going to Settings->Compiler & Debugger -> Toolchain executables but everything seems file in there:
Compiler Installation Directory: /usr (I used auto-detect)
C compiler:                gcc
C++ compiler:            g++
Linker for dynamic:     g++
Linker for static:         ar
debugger:                  gdb
make:                       make
Please help!
Edit: g++, gcc and gdb are installed and work fine on my machine.

 
« Last Edit: March 04, 2012, 03:38:59 pm by FSM »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Cannot compile on Linux
« Reply #1 on: March 04, 2012, 05:10:26 pm »
Read this: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29

Is there a chance that your project is using a custom makefile instead of the codeblock's build system?
If this is the case, you'll have to check your makefile and fix the errors in it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline FSM

  • Single posting newcomer
  • *
  • Posts: 3
Re: Cannot compile on Linux
« Reply #2 on: March 04, 2012, 05:21:16 pm »
I do not think so.
"This is a custom makefile" is not checked. Is there any chance that the custom makefile is still used without that checkmark being checked?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Cannot compile on Linux
« Reply #3 on: March 04, 2012, 05:24:20 pm »
Then you read the link and fix your project settings.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline FSM

  • Single posting newcomer
  • *
  • Posts: 3
Re: Cannot compile on Linux
« Reply #4 on: March 04, 2012, 09:18:31 pm »
Thanks. I read the link and my programs were compiling with this command:
Code
g++ -Wall -fexceptions  -O2  -I/usr/lib/i386-linux-gnu/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread  -L/usr/lib/i386-linux-gnu -pthread -Wl,-Bsymbolic-functions -Wl,-z,relro  -L/usr/lib/i386-linux-gnu   -lwx_gtk2u_richtext-2.8 -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8   -I/usr/lib/i386-linux-gnu/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -L/usr/lib/i386-linux-gnu -pthread -Wl,-Bsymbolic-functions -Wl,-z,relro  -L/usr/lib/i386-linux-gnu   -lwx_gtk2u_richtext-2.8 -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8   -I/usr/lib/i386-linux-gnu/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -L/usr/lib/i386-linux-gnu -pthread -Wl,-Bsymbolic-functions -Wl,-z,relro  -L/usr/lib/i386-linux-gnu   -lwx_gtk2u_richtext-2.8 -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8   -pthread -c /home/kkostya/Desktop/KLib/main.cpp -o obj/main.o
and the words "to" and "LDFLAGS" weren't needed. Now, how do I remove this extra commands from Code::Blocks compiler, so it will not use them when generating my programs?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Cannot compile on Linux
« Reply #5 on: March 04, 2012, 09:24:09 pm »
You have to find where are they being set.
Settings -> Compiller -> [your compiler]
or Project -> Build options (check also the options set by the target).

Also does a simple console project build and run?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Cannot compile on Linux
« Reply #6 on: March 04, 2012, 11:59:07 pm »
Thanks. I read the link and my programs were compiling with this command:
Code
g++ -Wall -fexceptions  -O2  -I/usr/lib/i386-linux-gnu/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread  -L/usr/lib/i386-linux-gnu -pthread -Wl,-Bsymbolic-functions -Wl,-z,relro  -L/usr/lib/i386-linux-gnu   -lwx_gtk2u_richtext-2.8 -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8   -I/usr/lib/i386-linux-gnu/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -L/usr/lib/i386-linux-gnu -pthread -Wl,-Bsymbolic-functions -Wl,-z,relro  -L/usr/lib/i386-linux-gnu   -lwx_gtk2u_richtext-2.8 -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8   -I/usr/lib/i386-linux-gnu/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -L/usr/lib/i386-linux-gnu -pthread -Wl,-Bsymbolic-functions -Wl,-z,relro  -L/usr/lib/i386-linux-gnu   -lwx_gtk2u_richtext-2.8 -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8   -pthread -c /home/kkostya/Desktop/KLib/main.cpp -o obj/main.o
and the words "to" and "LDFLAGS" weren't needed. Now, how do I remove this extra commands from Code::Blocks compiler, so it will not use them when generating my programs?

This is surely not the whole build log, but it seems that you have the same stuff in global compiler settings, in per project setting and per target settings.

Looks like you call wx-config here with --c[xx]flags and with --libs.
It seems you lack some basic knowledge about the compile and link process.
Note C::B does building an executable in at least two steps: building the object-files and linking them (and the needed libs) together.
You mix this (linking parameters are not needed for compiling).

Be aware, that this forum/website does not teach basic programming stuff.
It's a C::B only site.

If you know what to do, but don't know how to do it in C::B, it's okay to ask here, but if you don't know how to basically build an executable, and wnats to know how you can do this, it violates our forum rules.

You can create projects with the wizard and check how things are setup there, and see what you did wrong.

In general it's not a good idea to put things in the global settings of a compiler, unless you need the stuff for each and every file and project you want to compile with his compiler.