Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I copied an example on U-tube, all i have is an include file and a simple c file which includes the include file (the include file constains '#include <python.h>). I copied the example, the directories are setup correctly as far as i can tell.

Visual Studio Message...

1>------ Build started: Project: CProjectVS2017, Configuration: Release Win32 ------
1>Object reference not set to an instance of an object.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

What could be going wrong??

What I have tried:

There are no helpfull error messages so i have no idea what to try...
Posted
Updated 19-Feb-19 7:44am
Comments
Richard MacCutchan 19-Feb-19 13:28pm    
You are trying to use a reference that has not been initialised to point to anything. But without seeing your code we have no way of guessing what or where. You describe this as the simplest C project, so where does Python come into it?
Member 14155761 20-Feb-19 11:48am    
There are only include statements, i was copying this example (but using VS 2017 instead of VS 2010)

Writing a C++ extension for Python 2.7 with Visual Studio - YouTube[^]

Embedding Python is not the simplest C project. You have to carefully follow the steps presented in a up-to-date tutorial.
 
Share this answer
 
Comments
Member 14155761 20-Feb-19 11:47am    
Only include statements, i was copying this example (but using VS 2017 instead of VS 2010)

Writing a C++ extension for Python 2.7 with Visual Studio - YouTube[^]
It could be that you need to compile as x64, see answer here: c++ - can't include Python.h in visual studio - Stack Overflow[^]
 
Share this answer
 
Comments
Member 14155761 19-Feb-19 13:02pm    
Hi thanks for the reply. Its not complaining about the Python.h include (although it does complain if i switch to 64 bit, i'm using 32 bit Python2.7).
Member 14155761 19-Feb-19 14:31pm    
There is no code, only the include file which contains #include <python.h>. The c file just contains #include <include.h>
Richard MacCutchan 19-Feb-19 16:55pm    
That makes no sense at all. You must have some code in your C source file.
Member 14155761 20-Feb-19 11:47am    
Only include statements, i was copying this example (but using VS 2017 instead of VS 2010)

Writing a C++ extension for Python 2.7 with Visual Studio - YouTube[^]
RickZeeland 20-Feb-19 13:42pm    
Apparently this worked in VS2010, but not any more in VS2017 ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900