It is difficult to understand for which SW components an application's CMakeLists.txt will need to do
target_link_libraries(app mbedTLS)
and for which it doesn't.
One possible solution is to divide the zephyr libraries into two types.
One type that is automatically linked with app, by boilerplate.cmake.
And another that is not.
Perhaps it could be kconfigured whether app should be linked with or not, with sensible
defaults per-library.
In any case, this seems like a solvable problem that is making the build system difficult to use
for application developers. So this should be fixed for 1.11.
I've check the project in ${ZEPHYR_BASE}/tests/subsys/fs/nffs_fs_api/
The test code seems no such problems.
Do you mean if I add this line https://github.com/zephyrproject-rtos/zephyr/blob/master/tests/subsys/fs/nffs_fs_api/CMakeLists.txt#L38 in my app CMakeLists.txt, the compile error will disappear?
Sorry, I only looked at the mbedTLS case. I'll have a look at the NFFS case as well ...
Do you mean if I add this line https://github.com/zephyrproject-rtos/zephyr/blob/master/tests/subsys/fs/nffs_fs_api/CMakeLists.txt#L38 in my app CMakeLists.txt, the compile error will disappear?
Yes, I can confirm that this works. So the NFFS and mbedTLS issues you were seeing shared the root cause that is described in this issue.
PS: Weird, I thought there was a FS library that could be linked with so you didn't have to select the FS implementation in the build scripts. But I can't find it ...
EDIT: Found it, subsys__fs is the name of the zephyr library that should be linked with for FS support.
zephyr_library_link_libraries(subsys__fs) https://github.com/jhedberg/zephyr/pull/2/files
I already test it when I say it, it works.
I've been looking for the solution for at lease 2 hours... until you shown up. You helped me a lot, thanks..
I also ran into the same issue when adding FAT support.
By including either:
zephyr_library_link_libraries(subsys__fs) or target_link_libraries(app subsys__fs) I was able to continue. However, this seems to add some tests to the build and I get multiple definitions of main(). Any tips?
zephyr/tests/ztest/libtests__ztest.a(ztest.c.obj): In function 'main':
zephyr/tests/ztest/src/ztest.c:274: multiple definition of 'main'
libapp.a(main.c.obj): ..build_folder/../main.c:101: first defined here
@koffes : To be clear, are you trying to build an application or a test?
If you are trying to build an application I would check if CONFIG_ZTEST was set, and if so find out why and/or turn it off.
Thank you. You were right, a CONFIG_ZTEST=y was part of the configuration.