Page 1 of 1

purebasic.asm:107: error: macho: sorry, cannot apply 32 bit…

Posted: Mon Jan 06, 2014 8:02 am
by Violet
purebasic.asm:107: error: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq_foo" for pointers.
I compiled a small C source code to a static library. I try to address and use the functions inside through the PureBasic Import : EndImport statements. However I get that error above on compile time. Any ideas what the cause can possibly be? I use a 64 Bit operating system, 64 Bit version of PureBasic and compiled the C code for x86_64 architecture. I contacted the developer who told me about the code being fully 64 bit compatible, he even wrote it on a 64 bit system with a 64 bit compiler.

I compiled the static library once with Xcode but also manually in the terminal, with no difference. I hoped, Xcode would use some flags I do not know about which make it work. That is what I used for manual compilation via terminal:

Code: Select all

gcc -c -o lib.o lib.c
ar rcs lib.a lib.o
I am using a freshly installed OS X Mavericks (no previously upgraded predecessor) with 64 Bit PureBasic (and probably the wrong gcc parameters)... Xcode command line tools are installed in most recent version, too (october 2013).

It appears like I dug up something special, nothing all over the internet about such issue related to PureBasic. I just found something on Github, but that was not related.

Workaround

Posted: Sun Jan 12, 2014 8:36 pm
by Violet
Even though it is not a solution but a workaround, I resolved this matter by compiling the source code as a dynamic library (*.dylib) instead of a static library. As apps on OS X are bundled anyway, it makes no difference in the final product (from the user's view). Even though I would have really liked to know what the cause for this odd error was.