🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

linking python libs in linux

Started by
2 comments, last by drowner 19 years, 10 months ago
Im trying to compile a c++ application that uses python as scripting language. But I cant find the correct gcc flags to do it. I have googled but I cant find any answer. Can somebody here give me an idea?
Advertisement
Here's the bits from an autoconf project that is more or less what you're asking for. The result is a C++ executable that starts a Python interpreter and dynamically loads (via Python) a C++ Python extension that exposes all the engine to the Python users (which is mainly scripting, game logic and AI). The key bits are in the configure.in listing where you get the linking flags from a python script via the package distutils.

Makefile.am that builds the executable
AM_CXXFLAGS=@CPPUNIT_CFLAGS@ -I../../src -I../../bindings/python -I../src @PYTHON_CXXFLAGS@LDADD=@CPPUNIT_LIBS@ ../../src/libengine.la ../../bindings/python/libpyengine.la LDFLAGS= @PYTHON_LDFLAGS@ -export-dynamic


from configure.in at the top-level
AM_PATH_PYTHON("2.2")AC_CHECK_HEADER( python${PYTHON_VERSION}/Python.h,        PYTHON_CXXFLAGS=-I/usr/include/python${PYTHON_VERSION},        AC_MSG_ERROR(the Game needs the Python headers to build))AC_SUBST(PYTHON_CXXFLAGS)AC_SUBST([PYTHON_LDFLAGS], [`${PYTHON} -c "import distutils.sysconfigs= distutils.sysconfig.get_config_var('LINKFORSHARED')if(s is not None): print s"` ] )
joeG
Ok, after fixing some mistakes I made, now works and generates makefile, but i got an error: cannot specify -o with -c or -S and multiple compialtions.
-c is to compile to object code only, so trying to output to one file with muliple inputs is impossible, as opposed to compiling into a solitary executable.

What I think you want to do is compile each file seperately into object code, and then use 'ar' to make one lib file..


then again, I could be wrong, and totally missed what you were talking about


EDIT:

FROM THE GCC MAN PAGE
--------------------------

-o file           Place output in file file.  This applies regardless to whatever sort of output is being produced, whether it be an           executable file, an object file, an assembler file or preprocessed C code.           Since only one output file can be specified, it does not make sense to use -o when compiling more than one input           file, unless you are producing an executable file as output.           If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in           source.o, its assembler file in source.s, and all preprocessed C source on standard output.
------------------------------------------------------------// TODO: Insert clever comment here.

This topic is closed to new replies.

Advertisement