Linux에서 libmodbus 라이브러리로 작업 할 때 많은 어려움이있을 것으로 예상됩니다.치명적인 오류 : modbus.h : 해당 파일이나 디렉토리가 없습니다.
sudo make install
명령을 사용하여 libmodbus를 설치했으나 make 후에는 C 라이브러리에서 라이브러리를 링크하려고 할 때 문제가 발생합니다. 지금은
내 메이크 같다 :
이all: test
test: main.o com.o
gcc main.o com.o -o test
main.o: main.c
gcc -c main.c -o main.o
com.o: com.c
gcc -c com.c -Wl,-rpath=/usr/local/lib -Wl,LIBDIR -o com.o
clean:
rm -rf *o test
내 파일 com.c에서이 같은 파일 modbus.h 포함
#include <modbus.h>
을 그리고 난 항상 오류가 발생합니다 :
fatal error: modbus.h: No such file or directory.
설치를 완료했을 때 도움이된다면 코드에서 다음과 같이 반환합니다.
If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the '-LLIBDIR' flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
참조가 (http://stackoverflow.com/questions/22697543/compiling-a-program-that-includes- [libmodbus'에서 C '가 포함 된 progam 컴파일]를 libmodbus-in-c)'main.o'와'com.o' 파일을 만드는 데 걸리는 어려움을 극복해야합니다. –