brechtsanders / xlsxio

XLSX I/O - C library for reading and writing .xlsx files
MIT License
417 stars 112 forks source link

Linker Error - Compiling in Mac OS High Sierra #59

Closed luiseherrera closed 4 years ago

luiseherrera commented 4 years ago

Hi Guys,

I've been trying to solve this compiling issue related to the linker, but I couldn't figure it out what's wrong, I've already check if the h files, the .lib and .a files are in where it should be, but is still not working(everything is where is supposed to be), this happens every time  I want to compile any example or even if I've created my own program, please let me know if someone knows what's going on[btw I have used make for the installation, same compilation error occur when I use CMake(all the dependencies area installed)]:

LL-MBP:examples Luis$ gcc example_xlsxio_write.c -v Apple LLVM version 10.0.0 (clang-1000.11.45.5) Target: x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.13.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name example_xlsxio_write.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 409.12 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0 -fdebug-compilation-dir /Users/eduardomartinez/Downloads/xlsxio-master/examples -ferror-limit 19 -fmessage-length 183 -stack-protector 1 -fblocks -fencode-extended-block-signature -fobjc-runtime=macosx-10.13.0 -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/tc/b86gv61x1ml32xmd56jpwc2h0000gn/T/example_xlsxio_write-b09c2e.o -x c example_xlsxio_write.c clang -cc1 version 10.0.0 (clang-1000.11.45.5) default target x86_64-apple-darwin17.7.0

include "..." search starts here:

include <...> search starts here:

/usr/local/include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -macosx_version_min 10.13.0 -o a.out /var/folders/tc/b86gv61x1ml32xmd56jpwc2h0000gn/T/example_xlsxio_write-b09c2e.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/lib/darwin/libclang_rt.osx.a Undefined symbols for architecture x86_64: "_xlsxiowrite_add_cell_datetime", referenced from: _main in example_xlsxio_write-b09c2e.o "_xlsxiowrite_add_cell_float", referenced from: _main in example_xlsxio_write-b09c2e.o "_xlsxiowrite_add_cell_int", referenced from: _main in example_xlsxio_write-b09c2e.o "_xlsxiowrite_add_cell_string", referenced from: _main in example_xlsxio_write-b09c2e.o "_xlsxiowrite_add_column", referenced from: _main in example_xlsxio_write-b09c2e.o "_xlsxiowrite_close", referenced from: _main in example_xlsxio_write-b09c2e.o "_xlsxiowrite_next_row", referenced from: _main in example_xlsxio_write-b09c2e.o "_xlsxiowrite_open", referenced from: _main in example_xlsxio_write-b09c2e.o "_xlsxiowrite_set_detection_rows", referenced from: _main in example_xlsxio_write-b09c2e.o "_xlsxiowrite_set_row_height", referenced from: _main in example_xlsxio_write-b09c2e.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

brechtsanders commented 4 years ago

Did you actually link with -lxlsxio_write?

luiseherrera commented 4 years ago

I've tried too:

gcc main.c -l:/usr/local/lib/libxlsxio_write.dylib -o test.o gcc main.c -l:/usr/local/lib/libxlsxio_write.a -o test.o

and throw me this:

main.c:9:1: error: expected identifier or '(' if ((handle = xlsxiowrite_open(filename, "MySheet")) == NULL) { ^ main.c:15:32: error: expected identifier xlsxiowrite_add_column(handle, "Col1", 16); ^ main.c:15:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] xlsxiowrite_add_column(handle, "Col1", 16); ^ main.c:15:1: error: conflicting types for 'xlsxiowrite_add_column' /usr/local/include/xlsxio_write.h:124:24: note: previous declaration is here DLL_EXPORT_XLSXIO void xlsxiowrite_add_column (xlsxiowriter handle, const char name, int width); ^ main.c:16:32: error: expected identifier xlsxiowrite_add_column(handle, "Col2", 0); ^ main.c:16:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] xlsxiowrite_add_column(handle, "Col2", 0); ^ main.c:16:1: error: conflicting types for 'xlsxiowrite_add_column' /usr/local/include/xlsxio_write.h:124:24: note: previous declaration is here DLL_EXPORT_XLSXIO void xlsxiowrite_add_column (xlsxiowriter handle, const char name, int width); ^ main.c:17:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] xlsxiowrite_next_row(handle); ^ main.c:17:22: error: a parameter list without types is only allowed in a function definition xlsxiowrite_next_row(handle); ^ main.c:21:1: error: expected identifier or '(' for (i = 0; i < 1000; i++) { ^ main.c:28:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] xlsxiowrite_close(handle); ^ main.c:28:19: error: a parameter list without types is only allowed in a function definition xlsxiowrite_close(handle); ^ 4 warnings and 8 errors generated.


It looks like is not detecting the source files

luiseherrera commented 4 years ago

Did you actually link with -lxlsxio_write?

Yes

luiseherrera commented 4 years ago

Never mind, I got it. newbie mistake duh. Thanks Brecht !!!.