Author Topic: code::blocks creats wrong paths to link some files  (Read 692 times)

Offline gaiusbonus

  • Single posting newcomer
  • *
  • Posts: 7
code::blocks creats wrong paths to link some files
« on: May 12, 2021, 12:21:56 pm »
I'm building a single file console program.
To get some text from  data.txt file I made an object file data.o.

Works fine if I do not include librarys from a path outside the project path.
g++  -o bin/Debug/kannweg data.o obj/Debug/main.o

When I include another library and do not close my project code::blocks generates the following :
g++  -o bin/Debug/kannweg obj/Debug/lib/cpp/JdDebug.o data.o obj/Debug/main.o

Then I close the project and open it again and rebuild:
g++  -o bin/Debug/kannweg obj/Debug/lib/cpp/JdDebug.o cpp/kannweg/data.o obj/Debug/cpp/kannweg/main.o

This leads to the following error:
g++: error: cpp/kannweg/data.o: Datei oder Verzeichnis nicht gefunden

Tried to add the projects path to the search directories, but that made no difference.
The real program has a great number of external includes, so the workaround of my second test is not applicable.
Any Ideas for a fix or workaround?
Linux Mint 20.1 | code::blocks 20.03 | g++ 9.3.0-17ubuntu1~20.04

Online BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2974
Re: code::blocks creats wrong paths to link some files
« Reply #1 on: May 12, 2021, 01:29:34 pm »
why do you add object files?
object files are not meant to be used as libraries... libraries (static libraries ending with .a or dynamiv libraries, ending with lib/dll) are meant to be added object that does not need to be recompiled...

what is your library?
How do you add libraries?
The right way to do it is Project->Build options->select your project name on the left->Linker settings->Link libraries

If you want to use object files, you should add the c/cpp file and let codeblocks generate the object file and link it accordingly

Offline gaiusbonus

  • Single posting newcomer
  • *
  • Posts: 7
Re: code::blocks creats wrong paths to link some files
« Reply #2 on: May 12, 2021, 02:11:35 pm »
At the moment I read 8 vertex- and fragment-shader from the filesystem. To evaluate the code on different hardware I share it with some people with powerfull hardware.
To avoid mistakes if they don't copy all files (we had that before) I want to include the shader files and some jpg images. The described way was the first thing I found for Linux. In Windows there would be resources.

But this is programming stuff and there may be better solutions (I will follow your hint)...

The question here is, why codeblocks changes the path wenn generating the g++ command.
Linux Mint 20.1 | code::blocks 20.03 | g++ 9.3.0-17ubuntu1~20.04