Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
So, I'm writing my own static library, and so far it was working well. I'm trying to implement Python in C++. To make it easier on myself, I put the calls to Python into their own function, Py_Arg:

C++
#include "exampleApp.h"

std::string test()
{
	char* paras[] = {"123", "345"};
	Py_Arg("test", "multiply", (char*)paras);
	return "";
}

int Py_Arg(char* fileName[], char* funcName[], char* argv[])
{
//And it runs the code required... it shouldn't be important in regards to my question...
}


And, in my header file "exampleApp.h"...

C++
#include <string>
#include <string.h>
#include <iostream>
#include "Python/Includes/Python.h"

std::string test();
int Py_Arg(char*, char*, char*);


And, in my app to test the library...

C++
#include "stdafx.h"
#include <exampleApp.h>

int main(int argc, char* argv[])
{
	test();
	std::system("PAUSE");
	return 0;
}


Now, in VS I have imported the exampleApp.lib library the test project. I also, as you can see, specified the header location. However, when I try to run the program...

C++
error LNK2001: unresolved external symbol "int __cdecl Py_Arg(char *,char *,char *)" (?Py_Arg@@YAHPAD00@Z)


When I remove the Py_Arg function completely from the library, it executes fine. But for some reason it can't see the Py_Arg function. Does this have to do with the char* arguments it takes? I'm kind of experimenting with the whole char*, char*[], const char[], etc right now and I'm very lost. Any help would be greatly appreciated.

Thanks in advance.
Posted
Comments
Sergey Alexandrovich Kryukov 18-Mar-13 14:47pm    
The library may be not linked correctly, check up its file path, etc.
—SA

1 solution

I'd say your function definition is wrong:
C++
int Py_Arg(char* fileName[], char* funcName[], char* argv[])

try instead
C++
int Py_Arg(char* fileName, char* funcName, char* argv)

That's at least what the linker is searching for.
 
Share this answer
 

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