Cmake and xlsxio on MacOS

14 views
Skip to first unread message

Brett

unread,
Dec 18, 2019, 6:10:23 AM12/18/19
to Connected Community HackerSpace
Hi everyone,

I'm having some issues using xlsxio on MacOS 10.15.1 (19B88)

The github page is here;

https://github.com/brechtsanders/xlsxio

I added

SET(CMAKE_MACOSX_RPATH 1)

to

CMakeLists.txt

and ran

cmake -G"Unix Makefiles"

make install.

The code I have written to test xlsxio is in this pastebin;

https://pastebin.com/FLwvvevk

I try and compile with clang using the following;

clang -ansi -Wall -pedantic my_app.c -o my_app

and get the following output;

Undefined symbols for architecture x86_64:

"_xlsxioread_open", referenced from:

_main in my_app-bafc96.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm still learning C and do not know how to proceed. Any help would be
appreciated.

Thank you,

Brett

below is the output of adding -v to the clang command

Apple clang version 11.0.0 (clang-1100.0.33.16)

Target: x86_64-apple-darwin19.0.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.15.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 my_app.c
-mrelocation-model pic -pic-level 2 -mthread-model posix
-mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables
-target-sdk-version=10.15 -target-cpu penryn -dwarf-column-info
-debugger-tuning=lldb -ggnu-pubnames -target-linker-version 530 -v
-resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
-I/usr/local/include -Wall -Wno-framework-include-private-from-public
-Wno-atimport-in-framework-header -Wno-extra-semi-stmt
-Wno-quoted-include-in-framework-header -pedantic -std=c89
-fdebug-compilation-dir /Users/brett/Code/C/excel -ferror-limit 19
-fmessage-length 191 -stack-protector 1 -fstack-check
-mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature
-fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.15.0
-fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o
/var/folders/qr/3t03bs4j17b0z50vp7j2sn3c0000gn/T/my_app-846548.o -x c
my_app.c

clang -cc1 version 11.0.0 (clang-1100.0.33.16) default target
x86_64-apple-darwin19.0.0

ignoring nonexistent directory
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"

ignoring nonexistent directory
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"

#include "..." search starts here:

#include <...> search starts here:

/usr/local/include

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/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.15.0
-syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
-o my_app /var/folders/qr/3t03bs4j17b0z50vp7j2sn3c0000gn/T/my_app-846548.o
-L/usr/local/lib -lSystem
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/lib/darwin/libclang_rt.osx.a

Undefined symbols for architecture x86_64:

"_xlsxioread_open", referenced from:

_main in my_app-846548.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)



--
"If you are new to UNIX, you may be used to clicking something and
seeing either an "OK" message, an error, nothing, or (all too often) a
pretty blue screen with nifty high-tech letters' explaining exactly
where the system crashed" - Michael Lucas

brett

unread,
Jan 18, 2020, 12:46:21 AM1/18/20
to Connected Community HackerSpace

Hi everyone,

On 18/12/19 10:10 pm, Brett wrote:

Hi everyone,

I'm having some issues using xlsxio on MacOS 10.15.1 (19B88)

I *was* having issues but seemed to solve my own problem.

In hindsight it seems obvious. I was using CLion from Jetbrains as an IDE.

I try and compile with clang using the following;

clang -ansi -Wall -pedantic my_app.c -o my_app

and get the following output;

Undefined symbols for architecture x86_64:

  "_xlsxioread_open", referenced from:

      _main in my_app-bafc96.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

I can confirm that it was a linking problem both on the command line and in CLion

I had to add the following to CMakeLists.txt

include_directories(/usr/local/include/)
include_directories(/usr/local/lib/)


link_directories(/usr/local/lib/)


add_executable(My_Application main.c libxlsio_write.a libxlsio_read.a )
target_link_libraries(My_Application xlsxio_read xlsxio_write)


Which seemed to eliminate the problem. The application now successfully compiles and runs.

I am posting this in case someone else has linking issues with XLSXIO or linking with CMake

I know excel spreadsheets can be accessed easily using Python, I'm using C because it is what I

am studying at RMIT at the moment.


Thanks,

Brett

Reply all
Reply to author
Forward
0 new messages