Author Topic: Seems that my CB dosen't work in right directory  (Read 2892 times)

Offline hsxfjames

  • Single posting newcomer
  • *
  • Posts: 3
Seems that my CB dosen't work in right directory
« on: January 31, 2016, 01:51:54 pm »
Hi!
When I press Ctrl+F9 to build my project, I found " obj/Debug/main.o||No such file or directory|" in Build messages window. I switched to Build log window and the log is as follow(my system is Ubuntu15.10 and g++ version is g++5):

g++ -Wall -fexceptions -g  -c /home/hsxfjames/Destop/tst/main.cpp -o obj/Debug/main.o
g++  -o bin/Debug/tst obj/Debug/main.o 
g++: error: obj/Debug/main.o: No such file or directory

It seems is a compiler problem, but when I cd to that directory where main.cpp is, using the same command is OK.
I think maybe there is any thing wrong in my project settings or CB settings, so I created a new project and typed some easy code such like puts("hello world"); but recieved same message. To delete CB profiles(located at ~/.config/codeblocks for CB16.01 and ~/.codeblocks for CB13.12) and reinstall CB is also the same.
I think this is a CB's problem, because if CB pass full directory for main.o to g++, it should work and compile successfully, or if CB's working directory is the project directory(where main.cpp locates at), it may also work.
If this is a bug in CB or anything being imcompatible?
Thanks in advance

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: Seems that my CB dosen't work in right directory
« Reply #1 on: January 31, 2016, 02:13:53 pm »
g++  -o bin/Debug/tst obj/Debug/main.o 
That line looks bad and likely you setup your project file wrong. Can you post the (stripped) project here (zipped, please)?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline hsxfjames

  • Single posting newcomer
  • *
  • Posts: 3
Re: Seems that my CB dosen't work in right directory
« Reply #2 on: January 31, 2016, 02:48:26 pm »
That line looks bad and likely you setup your project file wrong. Can you post the (stripped) project here (zipped, please)?
My project name is "tst".
Here I uploaded two attachments, "tst.zip" is that project, and is only a simple program use boost.asio, and it should be compiled with -lboost_system parameter. I also created a simple project that is auto generated by CB to print "Hello world!" to console, is in "test-helloworld.zip".
« Last Edit: January 31, 2016, 03:14:30 pm by hsxfjames »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: Seems that my CB dosen't work in right directory
« Reply #3 on: January 31, 2016, 04:59:46 pm »
Here I uploaded two attachments, "tst.zip"

Sorry to say that, but with 16.01 (MinGW) I see for tst:

-------------- Build: Debug in tst (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions -g -Wshadow -Winit-self -Wredundant-decls -Wundef -Wunreachable-code -Wmissing-declarations -Wmissing-include-dirs -Wswitch-enum -Wswitch-default -Wextra -Wall -std=c++11 -std=gnu++11 -Wunused-local-typedefs -DwxUSE_WX_RESOURCES=0 -ID:\Devel\boost_1_60 -c main.cpp -o obj\Debug\main.o
mingw32-g++.exe -LD:\Devel\boost_1_60\lib -o bin\Debug\tst.exe obj\Debug\main.o   -lboost_system-mgw51-1_60 -lws2_32
Output file is bin\Debug\tst.exe with size 2.09 MB
Process terminated with status 0 (0 minute(s), 2 second(s))
0 error(s), 27 warning(s) (0 minute(s), 2 second(s))

And for helloworld:

-------------- Build: Debug in test-helloworld (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions -g -Wshadow -Winit-self -Wredundant-decls -Wundef -Wunreachable-code -Wmissing-declarations -Wmissing-include-dirs -Wswitch-enum -Wswitch-default -Wextra -Wall -std=c++11 -std=gnu++11 -Wunused-local-typedefs -DwxUSE_WX_RESOURCES=0  -c main.cpp -o obj\Debug\main.o
mingw32-g++.exe  -o bin\Debug\test-helloworld.exe obj\Debug\main.o   
Output file is bin\Debug\test-helloworld.exe with size 1.51 MB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))


So both projects compile for me just fine (you can safely ignore the additional -W[warning] switches, they are not relevant.

The boost application crashes several times as you ignore every return parameter and access invalid object therefore.

Please post the complete build log (similar to mine), see also my signature.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline hsxfjames

  • Single posting newcomer
  • *
  • Posts: 3
Re: Seems that my CB dosen't work in right directory
« Reply #4 on: February 01, 2016, 08:05:39 am »
So both projects compile for me just fine (you can safely ignore the additional -W[warning] switches, they are not relevant.

The boost application crashes several times as you ignore every return parameter and access invalid object therefore.

Please post the complete build log (similar to mine), see also my signature.
Sorry for my modifying the path of main.cpp in log, the original path have non-Latin characters, so the original complete build log is as follow:

-------------- Build: Debug in tst (compiler: GNU GCC Compiler)---------------

g++ -Wall -fexceptions -g  -c /home/hsxfjames/桌面/tst/main.cpp -o obj/Debug/main.o
g++  -o bin/Debug/tst obj/Debug/main.o  -lboost_system 
Output file is bin/Debug/tst with size 510.12 KB
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 0 warning(s) (0 minute(s), 1 second(s))

And the problem is clear: the path is wrong, it can't contain any of non-Latin characters. Since I change my system language to English or move the project folder to other place, CB works well.
So sorry for wasting your time and thanks your answer very much. It's my mistake. But I still have a doubt: though the path have non-Latin characters, CB works well under Ubuntu15.04. Only after I upgraded my system to Ubuntu15.10 did the problem appear. Is CB originally dose not support non-Latin characters in file paths all the time, or just only not support under Ubuntu15.10, or all is for my wrong system settings?
« Last Edit: February 07, 2016, 12:09:49 pm by hsxfjames »