Question

I get the following error when running make trying to compile WordNet 3.0:

gcc -m64  -g -O2   -o wishwn  wishwn-tkAppInit.o wishwn-stubs.o -L../lib -lWN -    F/Library/Frameworks -framework Tk -F/Library/Frameworks -framework Tcl -lpthread -framework CoreFoundation -framework Cocoa -framework Carbon -framework IOKit  -lz  -lpthread -framework CoreFoundation  
ld: warning: ignoring file /Library/Frameworks/Tk.framework/Tk, file was built for i386 which is     not the architecture being linked (x86_64): /Library/Frameworks/Tk.framework/Tk
Undefined symbols for architecture x86_64:
  "_Tk_Init", referenced from:
  _Tcl_AppInit in wishwn-tkAppInit.o
  "_Tk_MainEx", referenced from:
  _main in wishwn-tkAppInit.o
  "_Tk_SafeInit", referenced from:
  _Tcl_AppInit in wishwn-tkAppInit.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[2]: *** [wishwn] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

I'm running Tcl 8.6 installed via ActiveTcl.

Any ideas?

Was it helpful?

Solution

Each executable must (under all normal circumstances) be built for a single architecture, e.g., for just i386 (32-bit Intel-ish) or x86_64 (64-bit Intel-ish), as while it is possible to have a single CPU support multiple architectures, switching between them is formally a context switch and so is only done between the OS kernel and your code. (Some platforms — notably OSX — have supported multi-architecture binaries — “fat” binaries — in the past, but that's very much like having a single meta-architecture, and you're not supposed to do that now.) This in turn means that the libraries that are linked in, whether shared libraries or not, must also match the architecture you're building for.

Unfortunately, the libraries that you're trying to actually use are built for a different architectures: the ActiveState build you're trying to link against looks like it is for i386, yet you're trying to make a 64-bit version. That won't work.

The simplest way is probably to get the sources for Tcl and Tk and build them in the configuration you want; that's what I do on OSX, and it's easy. Grab the sources from the official release location on SourceForge. To build Tcl for OSX, run:

cd tcl8.6.1/unix
./configure --prefix=/where/you/will/install --enable-64bit
make
make test
sudo make install

You might pass in --enable-framework to configure (but I don't), you might omit the make test and you might not need to use sudo with make install (it depends on where you're installing to).

For Tk, you do:

cd tk8.6.1/unix
./configure --prefix=/where/you/will/install --enable-64bit --enable-aqua
make
sudo make install

You might need to pass in --with-tcl=/location/of/tclConfig.sh (where that's the tclConfig.sh that you just installed above) but the build scripts find it automatically if you've put the Tk sources next to the Tcl sources. There's a test suite for Tk, but it's much more intrusive than the Tcl one (since it has to pop up windows, steal the focus, grab the mouse pointer, that sort of thing; it's a GUI toolkit, so you should expect that sort of thing) which means I can totally understand you not running the unit tests.

OTHER TIPS

Make sure you have i386 and x86_64 listed in your Architectures in Build settings for your lib. Also set Build Active Architecture Only explicitly to No.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top