ldflags

How to set the LDFLAGS in CMakeLists.txt?

筅森魡賤 提交于 2019-11-26 12:04:12
问题 I set the CFLAGS in CMake by CMAKE_C_FLAGS. Is something like this to set LDFLAGS? 回答1: It depends a bit on what you want: A) If you want to specify which libraries to link to, you can use find_library to find libs and then use link_directories and target_link_libraries to. Of course, it is often worth the effort to write a good find_package script, which nicely adds "imported" libraries with add_library( YourLib IMPORTED ) with correct locations, and platform/build specific pre- and suffixes

How to use LDFLAGS in makefile

非 Y 不嫁゛ 提交于 2019-11-26 09:18:19
问题 I am new to Linux OS. I am trying to compile a .c file using a makefile. The math library has to be linked. My makefile looks like this: CC=gcc CFLAGS=-Wall -lm all:client .PHONY: clean clean: rm *~ *.o client When I run make , I get the following error: \"undefined reference to rint\" So it is not able to link the math library. But when I compile explicitly using gcc client.c -lm -o client it successfully compiles. So how should I change my makefile such that it works. I have already tried