什么可能导致这个未解决的外部符号异常? [英] What could be possibly causing this unresolved external symbol exception?
问题描述
所以,我正在编写自己的静态库,到目前为止它运行良好。我正在尝试用C ++实现Python。为了让自己更容易,我将调用Python放入他们自己的函数中,Py_Arg:
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:
#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...
}
在我的头文件exampleApp.h中......
And, in my header file "exampleApp.h"...
#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...
#include "stdafx.h"
#include <exampleApp.h>
int main(int argc, char* argv[])
{
test();
std::system("PAUSE");
return 0;
}
现在,在VS中,我已经将exampleApp.lib库导入了测试项目。如您所见,我还指定了标题位置。但是,当我尝试运行程序时...
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...
error LNK2001: unresolved external symbol "int __cdecl Py_Arg(char *,char *,char *)" (?Py_Arg@@YAHPAD00@Z)
当我从库中完全删除Py_Arg函数时,它执行正常。但由于某种原因,它无法看到Py_Arg函数。这是否与char *参数有关?我现在正在试验整个char *,char * [],const char []等等,我很迷茫。任何帮助将不胜感激。
提前谢谢。
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.
推荐答案
我会说你的功能定义错了:
I''d say your function definition is wrong:
int Py_Arg(char* fileName[], char* funcName[], char* argv[])
尝试改为
try instead
int Py_Arg(char* fileName, char* funcName, char* argv)
这至少是链接器正在搜索的内容。
That''s at least what the linker is searching for.
这篇关于什么可能导致这个未解决的外部符号异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!