Ceedling
Ceedling copied to clipboard
How properly to link a libraries?
Hello, I need to link my test project with -lpthread, in project.yml I had insert
:libraries: :placement: :end :flag: "-L ${1}" # or "-L ${1}" for example :common: &common_libraries [] :test: - -lpthread :release: - -lpthread
When I run it I get
Shell executed command: 'gcc "build/test/out/c/test_event_queue_runner.o" "build/test/out/c/test_event_queue.o" "build/test/out/c/unity.o" "build/test/out/c/my_event.o" "build/test/out/c/cmock.o" -o "build/test/out/test_event_queue.out"' And exited with status: [1]
And I didn't see there any libraries to link. What did I missed or where do I need to put -lpthread in .yml file?
System 4.15.0-34-generic #37~16.04.1-Ubuntu SMP Tue Aug 28 10:44:06 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux Ceedling:: 0.28.3 CMock:: 2.4.5 Unity:: 2.4.2 CException:: 1.3.1
Thanks for bringing this up. It appears that this feature was started but never finished. I see code for the release library support, but none for tests.
For now, you can try to add these to your linker step directly.
Memo to myself or anyone who decides to tackle this issue:
- It appears LIBRARY_TEST and LIBRARY_PLACEMENT are not used at all, thus far.
- The docs don't really cover this feature yet
- LIBRARY_SYSTEM is implemented, but also not documented
- There are examples already in the starter yamls
Oh... I see, thank you for an answer. I had been tried different ways from documentation and I found one which work in my case:
:tools: :test_compiler: :executable: gcc :arguments: - -Wall - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE #expands to -I search paths - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR #expands to -I search paths - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR #expands to all -D defined symbols - -c ${1} - -o ${2} :test_linker: :executable: gcc :arguments: - ${1} #list of object files to link (Ruby method call param list sub) - -lpthread - -o ${2} #executable file output (Ruby method call param list sub)
Not with :flags:
either with :libraries:
I can't to make it works, only with :tools:
, so it is much more than enough for me.
I'm glad the tools method is working for you. I'll try to get libraries fixed up soon for future use!
Thanks, you do a great job)
One more thing, when I use ceedling gcov:all
the tools method with my flags for compiling and libraries for linking doesn't work. It looks like standard compiling settings are running in that moment, so I had to add flags -g -fprofile-arcs -ftest-coverage
to my tools settings and then run gcov
manualy on each function to look on coverage.
Or maybe there is some way to set gcov method with tools method?
Or maybe there is some way to set gcov method with tools method?
@olyuboch did you ever find a way to get ceedling gcov:all
to work with :tools:
configuration?
Or maybe there is some way to set gcov method with tools method?
@olyuboch did you ever find a way to get
ceedling gcov:all
to work with:tools:
configuration?
No I didn't)
I have a project that uses libjanson and ceedling and gcov work just fine.
This is what needs to be done for gcov to work with it:
:tools_gcov_linker:
:arguments:
- -ljansson
This is what needs to be done for gcov to work with it:
Thank you very much)
Let me know if you still have issues.
@kevlut are you running Ceedling v0.28.3? If so, consider building it from sources because #306 delivered some fixes to :libraries:
config feature, but they haven't been released as part of an official release yet.
@kevlut are you running Ceedling v0.28.3? If so, consider building it from sources because #306 delivered some fixes to
:libraries:
config feature, but they haven't been released as part of an official release yet.
@IvanRibakov scratch my previous comment--but I did also run into #306 along the way, so thanks for the heads up!
Are there any plans to make a release yet? I'm running into this issue as well
I'm not sure is this the correct way but I had to use -lm compiler switch to link the <math.h> into the test case and I did it with this
:executable: gcc
:arguments:
- ${1} #list of object files to link (Ruby method call param list sub)
- -o ${2} #executable file output (Ruby method call param list sub)
- -lm```
Hi there,
Thanks all for your inputs was very helpful for me, in order to summarize :
If you still have an issue with using pthread for ceedling and gcov please check the following yml configuration, it should solve your issue : (make sure to respect indentation very important !!!)
To copy paste : < :libraries: :placement: :end :flag: "${1}" # or "-L ${1}" for example :common: &common_libraries [] :test: - *common_libraries :release: - *common_libraries
:tools: :test_compiler: :executable: gcc :arguments: - -Wall - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE #expands to -I search paths - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR #expands to -I search paths - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR #expands to all -D defined symbols - -c ${1} - -o ${2} :test_linker: :executable: gcc :arguments: - ${1} #list of object files to link (Ruby method call param list sub) - -lpthread - -o ${2} #executable file output (Ruby method call param list sub) :tools_gcov_linker: :arguments: - -lpthread
:plugins:
:enabled:
- stdout_pretty_tests_report
- module_generator
- gcov
- xml_tests_report
...
FYI :
Save your time messing around with :tools:
, instead use :libraries:
. I added winmm
under :test:
like this:
:libraries:
:placement: :end
:flag: "-l${1}"
:path_flag: "-L ${1}"
:system: [] # for example, you might list 'm' to grab the math library
:test: # []
- winmm # my project needs this
:release: []