c - python-dev: how to change library architecture -


i trying use python-dev api running few issues.

this code trying compile

#include <stdio.h> #include <signal.h> #include <unistd.h> #include <python.h>  int main(int argc, char *argv[]) {   py_setprogramname(argv[0]);  /* optional recommended */   py_initialize();   pyrun_simplestring("from time import time,ctime\n"                      "print 'today is',ctime(time())\n");   py_finalize();   return 0; } 

with

gcc -c test.c `python-config --cflags` 

first of, have python 2.7.8 installed in (osx 10.9) computer.

when run python-config --cflags output:

-i/library/frameworks/python.framework/versions/2.6/include/python2.6 -i/library/frameworks/python.framework/versions/2.6/include/python2.6 -fno-strict-aliasing -fno-common -dynamic -arch ppc -arch i386 -g -o2 -dndebug -g -o3 

so reason, though have python 2.7.8, python-dev api python 2.6. tried reinstalling python did me no good.

secondly, reason python trying use powerpc , i386 architecture -arch ppc -arc i386, fixed python-config --cflags | sed -e 's/-arch\ .*\ //g.

but though compiling code, linker still getting weird architecture code python-dev:

gcc test.o -o test `python-config --ldlags`  ld: warning: ignoring file /library/frameworks/python.framework/versions/2.6/lib/python2.6/config/libpython2.6.dylib, missing required architecture x86_64 in file /library/frameworks/python.framework/versions/2.6/lib/python2.6/config/libpython2.6.dylib (2 slices) undefined symbols architecture x86_64:   "_pyrun_simplestringflags", referenced from:       _main in test.o   "_py_finalize", referenced from:       _main in test.o   "_py_initialize", referenced from:       _main in test.o   "_py_setprogramname", referenced from:       _main in test.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) 

in homebrew github page found this:

ld: warning: ignoring file /library/frameworks/python.framework/versions/2.6/lib/python2.6/config/libpython2.6.dylib, missing required architecture x86_64 in file /library/frameworks/python.framework/versions/2.6/lib/python2.6/config/libpython2.6.dylib (2 slices) looks have 32-bit version of python installed - powerpc/i386. since have 64-bit computer, need default python have 64-bit component too.

but never explained how that.

how can api work?

update - compiling cflags gets rid of ignored files still gives me undefined symbols:

gcc test.o -o test `python-config --cflags --ldflags | sed -e 's/-arch\ .*\ //g' | sed -e 's/versions\/2\.6/versions\/current/g'` undefined symbols architecture x86_64:   "_pyrun_simplestringflags", referenced from:       _main in test.o   "_py_finalize", referenced from:       _main in test.o   "_py_initialize", referenced from:       _main in test.o   "_py_setprogramname", referenced from:       _main in test.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) 

update - problem python installed in /usr/local/cellar/frameworks in machine reason python-config still thinks it's in /library/frameworks. real question is: how change path python-config? pythonpath env variable correct, have no clue why not changed.

you passing compiler flags. pass linker flags well. otherwise, libraries symbols not linked:

gcc -c test.c `python-config --cflags --ldflags` 

to solve undefined symbols problem, python-config using wrong interpreter. open python-config (it regular python file) @ which python-config , check first line #!/library/frameworks/python.framework/versions/2.6/bin/python2.6 if not point right interpreter, change correct path.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -