0

I faced a problem when i migrated a project from Linux to windows for the visual studio seem can not use dll lib directly. I look through a number of materials and known i seem should use IMPORTED in add_library(...), but i can not find a practical example about how to use it and i used it like this:

add_library(hello_lib SHARED hello.c) add_library(hello_lib SHARED IMPORTED) 

And a ERROR happened

CMake Error at sub_haha/CMakeLists.txt:6 (add_library): add_library cannot create imported target "haha_lib" because another target with the same name already exists. 

Could you please give me one or some? BTW the dll lib seem could be used in Mingw makefile on windows.

4
  • As error message tells, you cannot create two targets with same name. Choose another name for imported library. Commented Apr 25, 2016 at 6:52
  • @Tsyvarev, I know this error, i just do not know how to use it to link dll in windows. Commented Apr 25, 2016 at 6:54
  • For link with library target_link_libraries command should used, as usual. Do not understand your problem. Commented Apr 25, 2016 at 6:57
  • For some details on creating/using shared libraries in CMake see e.g. here or here. Commented Apr 25, 2016 at 17:04

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.