0

i'm trying to develop a small scaled application to exchange data between a pc and a plc using the snap7 Libary.

I installed snap7 via brew and edited my cmake with the following lines

include_directories(/usr/local/Cellar/snap7/1.4.2_1/include)
link_directories(/usr/local/Cellar/snap7/1.4.2_1/lib)

so far so good i can now do this

#include <snap7.h>

but when i try to build the application (using CLion on macOS 10.13.3 with XCode Version 9.2 (9C40b)

i get the following error

Undefined symbols for architecture x86_64:
  "TS7Client::TS7Client()", referenced from:
  _main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Zebra_TCP] Error 1
make[1]: *** [CMakeFiles/Zebra_TCP.dir/all] Error 2
make: *** [all] Error 2
bhmth
  • 51
  • 6
  • Is the `snap7`-library compiled for 64 bit architecture? – Stephan Lechner Mar 21 '18 at 19:27
  • via brew i only get the libsnap7.dylib / snap7.h files directly in /usr/local/cellar. however if you download the source directly there is the option to recompile the libary for every given architecture – bhmth Mar 21 '18 at 19:41
  • Possible duplicate of [CMake link to external library](https://stackoverflow.com/questions/8774593/cmake-link-to-external-library) – Tsyvarev Mar 21 '18 at 19:47
  • In short: neither `include_directories` nor `link_directories` command **links** to the library. You need to use `target_link_libraries` command. – Tsyvarev Mar 21 '18 at 19:48
  • edited my cmake like this: FIND_LIBRARY(LIB snap7) TARGET_LINK_LIBRARIES(${PROJECT} "${LIB}") TARGET_INCLUDE_DIRECTORIES(${PROJECT} PUBLIC /usr/local/Cellar/snap7/1.4.2_1/include) but still getting the same error – bhmth Mar 21 '18 at 20:20

0 Answers0