-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble linking #2
Comments
It may be necessary to compile your code with the macro |
In fact since posting, I tried with Py_NO_ENABLE_SHARED defined, and got past the __imp prefix thing. I also found the blog post you did about this with the extra flags, so switched from building my project in VS 2015 to the command line environment. I actually tried both from the 7.1 SDK and from the VS2015 developer prompt with different resutls. I will continue to research the issues below. I understand it is a fairly old project but it would be great to resurrect it. If you did happen to have an old sample projects you could share that builds successfully against the static lib, I would be very grateful. Here is my make file based on your flags:
The code is very simple:
A sample of some link issues. 7.1 SDK:
VS 2015 Dev env:
|
I think the "already defined" error points to the python.lib and your code not being compiled with the same flags or compiler. Especially the /MT or /MD switches have to match in both builds. |
I have managed to build the executable now. Thanks for your help with this Christian. Actually required me to just get my head down and learn how it all works. It wasn't those switches in fact, but some changes to my Makefile did it for me. Had to include the extra libraries shown below and change the nodefaultlib switch:
Incidentally, to get the initial lib built on Windows 10, some modifications of the process in your README were necessary. I didn't mention this before, but now I have a build it might help someone else get there: Windows 10 Notes:
http://stackoverflow.com/questions/32091593/cannot-install-windows-sdk-7-1-on-windows-10
|
I have now started to try to get your examples/embed.c working, and have made some progress, but I am stuck with this:
I can't find any reference to that function. In fact, if you google it, it leads you back to this project as the only result. Did I misunderstand this example? Should it be possible to compile it without any extra resources? |
No, if you don't have a custom importer ready, you can just delete lines 19-40 in the example. Sorry about the confusion! |
I am sure it would have been obvious if I had really studied the code, but I am new to c and Python, so looking for as many clues as I can get. My interest in your sample code is that it seems I could use it towards my goal, which is to create an standalone executable containing a specific package I have. This package calls for numpy and scipy, so I was hoping that using the direction in your example, I could perhaps call these two libraries at runtime rather than trying to statically build them into pythonembed.lib, which I know will be hard. |
Well, writing a custom importer without knowing details about Python and it's C API will be hard - but doable! Linking numpy and scipy statically will probably be a similar effort to what I did in the project here. |
Ok. But do I actually need to write a custom importer. Can I not just I am happy to bundle the external ready made libraries, so it isn't
|
You need a custom importer if you want to ship a single binary file, which can not rely on external files -- by default, even the static python lib will load (pure) Python modules (resembling the standard library) from an external folder. |
Very grateful for your engagement on this Christian. Let me make it clear, as I mentioned, I am happy to rely on external files. I do not need to ship a single binary. What I want is to build some stuff, or to be precise, my stuff into the binary. Public stuff like numpy and scipy I don't mind if my new Python calls these externally as normal Python would. In fact it's better. |
I see what you mean, you can't have a statically linked python load c extensions. So as you say I'll have to try to build Numpy and Scipy statically. Wish me luck. |
Hi,
I am testing out your statically compiled interpreter, and it seems to build fine.
I have a test project I'm using to see if I can link to it, and I have this compilation error:
Error 1 error LNK2019: unresolved external symbol __imp__Py_Initialize referenced in function _main static_python_test.obj static_python_test_2
Running dumpbin /all on my generated pythonembed.lib shows that the expected symbols are there:
B297C2 _Py_Initialize
But I don't understand why the linker is looking for __imp__Py_Initialize and not _Py_Initialize.
Are you able to point me in the right direction please?
Thanks,
James
The text was updated successfully, but these errors were encountered: