User forums > Using Code::Blocks
Can CB use a linux shell script to build a project?
Marnix:
I use CB on linux mint.
I have a C/C++ project that I must build from the command line, by running a shell script.
This is what the script looks like (I removed .c and .o filenames)
====================================================
OPT="-g -I../common -I../ifi -DIFI_BUILD -DLOG_MT -DLOGGING"
# xvan c-files
XVAN="<file list removed>"
# xvan o-files
XVANO=”<file list removed>"
# compile the C files
gcc -c -fPIC $OPT $XVAN
# compile the C++ and link into shared lib (linux)
g++ -fPIC -shared -o ifigame.so -std=c++11 $OPT ifixvan.cpp ../ifi/ifiglue.cpp $XVANO
# compile console front end, link with shared lib (linux)
g++ -std=c++11 $OPT -DIFI_IMPORT -o ificonsole ../ifi/ificonsole.cpp -L. -l:ifigame.so -pthread
====================================================
I want to build the project in CB so I can debug it.
Is there a way I can tell CB to use the .sh file to build the project? Or, alternatively, do we have instructions how to "translate" a .sh to CB build settings?
I hope someone can answer this.
sodev:
I have seen a lot of shit, but this is the first time that i see someone building code on linux with a shell script ;D. Use a Makefile to build your code, shouldn't be that hard to turn your script into one because it is already closely structured like one.
Then you can create a CodeBlocks project that uses an external Makefile, however certain things don't work in CodeBlocks then, i don't know how much debugging is affected.
If u just need to track a crash, you could also run your application directly under gdb in a shell ;)
oBFusCATed:
--- Quote from: sodev on June 02, 2018, 04:15:57 pm ---I have seen a lot of shit, but this is the first time that i see someone building code on linux with a shell script ;D.
--- End quote ---
It will be good if you can start to watch your language a bit.
Shell scripting is pretty common when people doesn't bother to learn make syntax or just want to hack something fast.
--- Quote from: sodev on June 02, 2018, 04:15:57 pm ---Then you can create a CodeBlocks project that uses an external Makefile, however certain things don't work in CodeBlocks then, i don't know how much debugging is affected.
--- End quote ---
@Marnix: The above is true even for your shell script. But you have to change the makefile executables to match your settings. But if this is the full shell script it would be a lot easier if you create a cb project. I don't see anything that the UI can't do.
Also you can always attach to your executable if it is waiting for user input as last resort.
Marnix:
--- Quote from: oBFusCATed on June 02, 2018, 05:45:57 pm ---....... But if this is the full shell script it would be a lot easier if you create a cb project. I don't see anything that the UI can't do.......
--- End quote ---
Yes I would prefer a CB project, but don't know how to translate the shell script to CB settings. I've used CB for a quite some time, but my applications always were c-files and header files.
From this script, someone gave it to me, I see that:
- first, it compiles the c-files to object files;
- next, it creates a .so file from the object files and some other files.
- finaly, it creates the application with the .so file and a cpp file.
Can this all be done in 1 CB project?
oBFusCATed:
Yes, it can. The projects used to build C::B are like this.
The idea is:
1. create two targets
2. name them library and application
3. make sure library is above application
4. make a virtual target to group both targets
5. build the virtual target (it will build its targets from top to bottom)
Navigation
[0] Message Index
[#] Next page
Go to full version