|
From: David F. <dav...@in...> - 2015-03-31 16:27:38
|
Hi Carlos, The second g++ invocation tries to link steam_api and python libraries and steamworks_wrap.o object into an executable (a.out by default), but there is no 'main' function. You should create a shared library instead, which you can later import from Python, something like this: g++ -L/Users/aarzee/Documents/steamworks-sdk/redistributable_bin/osx32 -shared -o -libpysteam_api.dylib -lsteam_api -lpython steamworks_wrap.o However, some other flags may be need, and using a setup.py file would be more reliable. Hope it helps, David Quoting Carlos Liam (2015-03-31 17:31:27) > I'm not sure if this is the right place to ask, but I'm not sure where else to look. I went on Stack Overflow ( http://stackoverflow.com/questions/29358095/issue-with-undefined-symbol-main-when-compiling-swig-wrapper ) but haven't received an answer. > > I'm on Mac OS X 10.10.2 (64-bit) and I have the swig and swig-python packages installed through MacPorts, as well as Xcode and the command line tools installed. > > I'm trying to create a wrapper from the Steamworks C++ API to Python. I have the following interface file (steamworks.i): > > %module steamworks > %{ > #define SWIG_FILE_WITH_INIT > #include "/Users/aarzee/Documents/steamworks-sdk/public/steam/steam_api.h" > %} > > I'm running these commands: > > swig -c++ -python steamworks.i > g++ -O2 -fPIC -c steamworks_wrap.cxx -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 > g++ -L/Users/aarzee/Documents/steamworks-sdk/redistributable_bin/osx32 -lsteam_api -lpython steamworks_wrap.o > > The first two commands seem to work fine, but when I do the second g++ invocation, I get this error: > > Undefined symbols for architecture x86_64: > "_main", referenced from: > implicit entry/start for main executable > ld: symbol(s) not found for architecture x86_64 > clang: error: linker command failed with exit code 1 (use -v to see invocation) > > I did a little research on this and it seems that this can be caused by premature linking, but I am using the -c option in the first g++ invocation. > > Any help would be appreciated. > > - CL > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming The Go Parallel Website, sponsored > by Intel and developed in partnership with Slashdot Media, is your hub for all > things parallel software development, from weekly thought leadership blogs to > news, videos, case studies, tutorials and more. Take a look and join the > conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user -- David Froger SED-PRO "C++ may not be the worst programming language ever created, but without a doubt it’s the worst ever to be taken seriously." -- Mason Wheeler |