c++ - How to make my project files with static library (Snappy) -
i have project using snappy library , makefile it:
cxx=g++ cxxflags=-c -wall lflags= objs=main.o utilities.o framingformat.o crc32.o snappy.out: $(objs) $(cxx) $(lflags) $^ -o $@ $(objs): %.o:%.cpp $(cxx) $(cxxflags) $< -o $@ clean: -rm -rf *.o .phony: clean
snappy library has been built earlier.
now run makefile have errors:
g++ main.o utilities.o framingformat.o crc32.o -o snappy.out framingformat.o: in function `compresstoframe(char*, unsigned long, char*, unsigned long*)': framingformat.cpp:(.text+0x5b): undefined reference `snappy_compress' framingformat.o: in function `uncompressfromframedata(char*, unsigned long, char*, unsigned long*)': framingformat.cpp:(.text+0x14a): undefined reference `snappy_uncompress' framingformat.o: in function `maxframelength(unsigned long)': framingformat.cpp:(.text+0x2bf): undefined reference `snappy_max_compressed_length' framingformat.o: in function `uncompresseddatalength(char*, unsigned long, unsigned long*)': framingformat.cpp:(.text+0x2f8): undefined reference `snappy_uncompressed_length' collect2: error: ld returned 1 exit status make: *** [snappy.out] error 1
it because makefile don't know i'm using snappy libs how solve problem? it's directories:
- snappy/catalog-with-snappy
- snappy/catalog-with-project-using-snappy
[edit] makefile looks this:
cxx=g++ cxxflags=-c -wall lflags= objs=main.o utilities.o framingformat.o crc32.o snappy.out: $(objs) $(cxx) $(lflags) $^ -l"../../snappylib1.1.2/snappylib1.1.2" -o $@ $(objs): %.o:%.cpp $(cxx) $(cxxflags) $< -l"../../snappylib1.1.2/snappylib1.1.2" -o $@ clean: -rm -rf *.o .phony: clean
use -lsnappy in linker option, presuming have snappy.so or snappy.a in accessible directory. or may have use directory explicitly
Comments
Post a Comment