Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Can I fix 'Undefined symbols for architecture x86_64'? (10.13)

I have g++ source code that successfully compiles and links with -m32 option. When I take that option away, I get several errors linking one of the source's object. The error is as follows:

=====================================================

g++ -o em3elf em.o emain.o emsvc.o emelf.o emtrap.o emdevs.o emproc.o emacts.o empars.o emsort.o emsrch.o emfuns.o emserv.o emfmtp.o emcps.o emgetl.o emwyl.o flock.o xlong.o -L/Users/dickguertin/newspi/elf -lelf -v

Apple LLVM version 9.1.0 (clang-902.0.39.2)

Target: x86_64-apple-darwin17.6.0

Thread model: posix

InstalledDir: /Library/Developer/CommandLineTools/usr/bin

"/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -dynamic -arch x86_64 -macosx_version_min 10.13.0 -o em3elf -L/Users/dickguertin/newspi/elf em.o emain.o emsvc.o emelf.o emtrap.o emdevs.o emproc.o emacts.o empars.o emsort.o emsrch.o emfuns.o emserv.o emfmtp.o emcps.o emgetl.o emwyl.o flock.o xlong.o -lelf -lc++ -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/lib/darwin/libclang_rt. osx.a

ld: warning: ignoring file /Users/dickguertin/newspi/elf/libelf.a, file was built for archive which is not the architecture being linked (x86_64): /Users/dickguertin/newspi/elf/libelf.a

Undefined symbols for architecture x86_64:

"display_mode_set(model_terminal_public*)", referenced from:

strtScreen() in emelf.o

"display_mode_read(model_terminal_public*, int, unsigned char*, int, long, int*)", referenced from:

CRTread(unsigned char*, int*) in emelf.o

"display_mode_clear(model_terminal_public*)", referenced from:

CRToff() in emelf.o

"display_mode_write(model_terminal_public*, int, unsigned char*, int)", referenced from:

CRTwrite(unsigned char*, int) in emelf.o

"_modeltrmclass", referenced from:

CRToff() in emelf.o

CRTstart(unsigned char*, unsigned char*) in emelf.o

strtScreen() in emelf.o

"_unixportclass", referenced from:

strtScreen() in emelf.o

ld: symbol(s) not found for architecture x86_64

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

make: *** [em3elf] Error 1

=============================================

As you can see, I used the -v option to get as much info as possible. I suspect this is related to "termios" because this is the module that handles 'full-screen'. I can't use 'ncurses' either. Neither seem to be 64-bit compliant. I'm on Hight-Sierra. Any suggestions?

Posted on Nov 9, 2018 8:47 PM

Reply
Question marked as Best reply

Posted on Nov 9, 2018 9:35 PM

Sorry, I found the solution myself. I had 'long' declarations that mis-matched between '.c' and '.h' files. Once I corrected that, 64-bit mode 'full screen' compiled, linked, and worked. If I could delete this question, I would. But maybe my 'solution' is worth something to someone else. In order to have code that works in both 32-bit mode AND 64-bit mode, 'long' has to become 'int', except for cells that hold pointers. Thus, 'long* is a pointer to a 'long', which should become an 'int*', which is a long-pointer to an int-object. I now have transportable code across architectures.

Similar questions

1 reply
Question marked as Best reply

Nov 9, 2018 9:35 PM in response to dickguertin

Sorry, I found the solution myself. I had 'long' declarations that mis-matched between '.c' and '.h' files. Once I corrected that, 64-bit mode 'full screen' compiled, linked, and worked. If I could delete this question, I would. But maybe my 'solution' is worth something to someone else. In order to have code that works in both 32-bit mode AND 64-bit mode, 'long' has to become 'int', except for cells that hold pointers. Thus, 'long* is a pointer to a 'long', which should become an 'int*', which is a long-pointer to an int-object. I now have transportable code across architectures.

Can I fix 'Undefined symbols for architecture x86_64'? (10.13)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.