News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

How to use an already compiled library?

Started by cbun, March 17, 2021, 09:04:34 AM

Previous topic - Next topic

cbun

Hi, I'm new to Code:Blocks.
In my current C++ project I'm using a library (lib***.a) located with the header and source files in a certain folder.
I can compile and run my project but it does take ages to do so (over 2 min).
Instead of compiling just my file and using the library it does compile all of those files an shows a lot of warnings in those. It does this after each little change.
What did I miss?

Currently I'm using a newer version of the library. Before that I used an older version available in package sources of Ubuntu. But that needed an extra path as well.
Also had this Problem there. But somehow I managed it to work there (did also including restarting Code::Blocks).
Now I only get some short building time after building it once and dont change anything in code.



I did add the absolute folder path to:
- Project->Properties->C/C++ parser options
- Project->Properties->Debugger
- Project-> Build Options -> (select project name to the left) -> Search directories -> compiler
- Project-> Build Options -> (select project name to the left) -> Search directories -> linker
And did the path to the library itself:
- Project-> Build Options -> Compiler Settings -> Other resource compiler settings -> -l/pathto/libname.a
- Project-> Build Options -> Linker Settings


In console I can compile it with (in less than 5 sec):
g++ -o test ./main.cpp -L/pathtolibraryfolder/ -libname -I/pathtoheaderfolder_equalToLibfolder/


cbun

#2
Thank you for response BlueHazzard.
Today somehow it took 'only' 40 sec.

I checked the build log. It included a lot of warning from my included headers (from that library).
After changing '-Weverything' to '-Wall' in build options it did only show warnings for my file.
After changing this building took only 2 sec.

with this build log is:

Cleaned "myproject - Debug"

-------------- Build: Debug in myproject (compiler: LLVM Clang Compiler)---------------

clang++ -Wall -g -fexceptions -I/home/username/Downloads/libs/libraryname -c /home/username/Projects/CodeBlocks/myproject/main.cpp -o obj/Debug/main.o
clang++ -L/home/username/Downloads/libs/libraryname -o bin/Debug/myproject obj/Debug/main.o  -lraryname  /home/username/Downloads/libs/libraryname/libraryname.a
Output file is bin/Debug/myproject with size 22.18 MB
Process terminated with status 0 (0 minute(s), 2 second(s))
0 error(s), 0 warning(s) (0 minute(s), 2 second(s))


BlueHazzard

Yes, codeblocks has some problems with warnings, at least on windows...

oBFusCATed

(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!]