我试图将一个头文件和一个具有该类实际函数的.cpp文件链接到我的主cpp文件,但我得到了这个错误: c++ DataMembers.cpp -o DataMembers体系结构的未定义符号x86_64:“猫::eat()”,引用自:_main in DataMembers-053507.o“猫::x86_64 ()”,引用自:_main in DataMembers-053507.o“猫::睡眠()”,引用自:_main in DataMembers-053507.o ld:未找到体系结构的符号x86_64 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用) make:* D
我构建了一个简单的android应用程序,它使用ndk和JNI。这个应用程序有一个用于将java和c++与jni链接起来的onw .cpp(debugTest.cpp)文件和另一个带有其头文件(javaEssentials.h)的.c(javaEssentials.c)文件。当我在.cpp文件中包含.c文件(# include "javaEssentials.c")时,编译时没有报告错误。当我在.cpp文件中包含头文件时,编译器会报告函数引用未定义的错误,.c文件的has.It是一个非常奇怪的问题,我不明白为什么会发生这种情况。像往常一样,我在.c文件中包含了头文件的inclu
我在使用GNU g++编译多个文件时遇到了问题。
我们假设有五个文件:
main.cpp : the main function
a.h : the header file of class A
a.cpp : the definition of class A
b.h : the header file of class B
b.cpp : the definition of class B
在程序中,main.cpp使用A类(包括a.h),A类使用B类(因此包括b.h)。
所以,在我的主题词中,我刚刚添加了#包括"a.h“
我正在尝试用
g
我创建了一个包含多个源文件和头文件的C++项目。该程序在代码块中编译和运行良好,但我不能在终端中编译它。
所有文件都在同一个文件夹中。
下面是我输入的命令:
clang++ -std=c++11 main.cpp file1.cpp file1.h
它显示:
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
以及大量的错误:
error: use of undeclared identifier '
可能重复:
我最近一直在和C++打交道。目前,我正在尝试编写至少每个人都做过一次的程序:一个简单的LinkedList类。代码已经完成,但我不知怎么没能编译它。我一直在谷歌上搜索,似乎我把目标文件链接错了。我的代码就是这样的:
test.cpp
#include "linkedlist.h"
int main()
{
LinkedList<int> list;
// do something
}
linkedlist.h
template <typename T>
class LinkedList
{
// a lot
在c++共享库项目中,全局变量存在问题。我的库必须作为标准的g++共享库(.so)和dll工作。我是通过创建文件libiup_dll.cpp和libiup_dll.h来做到这一点的,在这两个文件中,我有如下所示
#ifdef BUILD_DLL
// code for the dll: wrapper functions around the classes in my shared library
#endif
在我的dll中,我需要函数setloglevel(int)和ge恐怖my ()。然后,在我的所有类中,我将向全局变量errormsg添加所有错误消息。然后,这个变量应该由ge恐怖
我有这样的代码:
在头文件中
class SocialNet {
private:
// some data
public:
// some other operations
template <typename T, typename V>
T find(V identifier, const vector<T>& objects) const;
};
在.cpp文件中
// in t
我正在制作一个处理扑克手和概率的简单程序。我正在用不同的手运行测试用例,在我的程序中,我需要一个平台来吸引我的手,它是恒定的和全局的。我的程序有三个主要目标:卡片,手,和甲板。我正在尝试创建一个全局平台,但似乎无论我做什么,我都会发现一个错误,即globalDeck在hand.cpp中是未定义的。以下是相关代码:
hand.cpp:
Hand::Hand(int &one, int &two, int &three, int &four, int &five)
{
cardsinHand.push_back(globalDeck.copy(one