首先,请原谅我对C++的不了解.我是一个真正的初学者!
我想在MS VS2005上编译一个C++代码.下面的代码我得到如下链接器错误: -
在一个函数(某个类方法)定义中,它具有用于内存分配的代码,如:
CDecoderUnit *du = new CDecoderUnit(); //<<error is shown at this line
Run Code Online (Sandbox Code Playgroud)
这个CDecoderUnit是一个在头文件中定义的类
class CDecoderUnit : public IPrepareDecoderUnit
{
CDecoderUnit();
~CDecoderUnit();
...
...
other class definition.
..
..
}
Run Code Online (Sandbox Code Playgroud)
实际错误是: -
错误LNK2019:未解析的外部符号"public:__thiscall CDecoderUnit :: CDecoderUnit(void)"(?? 0CDecoderUnit @@ QAE @ XZ)在函数"private:long __thiscall CLSDEnc :: CreateIPrepareDecoderUnit(struct IPrepareDecoderUnit*&)const"中引用(? CreateIPrepareDecoderUnit @ CLSDEnc @@ ABEJAAPAUIPrepareDecoderUnit @@@ Z)lsdenc.obj
谁能指点我解决这个问题?
安装Xerces-C ++(XML库)后:
./configure --disable-shared
./make
./make-install
ldconfig
Run Code Online (Sandbox Code Playgroud)
并编写简单程序(xmlval.cpp):
#include <stdio>
#include <xercesc/dom/DOM.hpp>
int main()
{
std::cout << "HI" << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
并编译:
/usr/bin/g++ -L/usr/local/lib -I/usr/local/include -o xmlval xmlval.cpp /usr/local/lib/libxerces-c.a
Run Code Online (Sandbox Code Playgroud)
编译结果是一串这样的代码:
/usr/local/lib/libxerces-c.a(CurlNetAccessor.o): In function `xercesc_3_0::CurlNetAccessor::cleanupCurl()':
/home/stullbd/xerces-c-3.0.1/src/xercesc/util/NetAccessors/Curl/CurlNetAccessor.cpp:78: undefined reference to `curl_global_cleanup'
/usr/local/lib/libxerces-c.a(CurlNetAccessor.o): In function `xercesc_3_0::CurlNetAccessor::initCurl()':
/home/stullbd/xerces-c-3.0.1/src/xercesc/util/NetAccessors/Curl/CurlNetAccessor.cpp:70: undefined reference to `curl_global_init'
/usr/local/lib/libxerces-c.a(CurlURLInputStream.o): In function `~CurlURLInputStream':
/home/stullbd/xerces-c-3.0.1/src/xercesc/util/NetAccessors/Curl/CurlURLInputStream.cpp:168: undefined reference to `curl_multi_remove_handle'
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
我使用的是ubuntu 10.04和libboost1.40.
ls -l /usr/lib | grep boost_pro
-rw-r--r-- 1 root root 640800 2010-04-01 05:19 libboost_program_options.a
lrwxrwxrwx 1 root root 26 2011-11-03 22:40 libboost_program_options-mt.a -> libboost_program_options.a
lrwxrwxrwx 1 root root 34 2011-11-03 22:40 libboost_program_options-mt.so -> libboost_program_options.so.1.40.0
lrwxrwxrwx 1 root root 34 2011-11-03 22:40 libboost_program_options.so -> libboost_program_options.so.1.40.0
-rw-r--r-- 1 root root 289336 2010-04-01 05:19 libboost_program_options.so.1.40.0
Run Code Online (Sandbox Code Playgroud)
这是main.cpp(仅用于测试)
#include <string>
#include <iostream>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/program_options/options_description.hpp>
//---------------------------------------------------------------------
int main(int argc,char** argv)
{
boost::gregorian::date now(boost::gregorian::day_clock::local_day());
//is works fine
std::cout<<boost::gregorian::to_iso_string(now)<<std::endl;
boost::program_options::options_description a; //but …Run Code Online (Sandbox Code Playgroud) 编辑一些代码后,我得到4个构建错误:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_Playlist", referenced from:
objc-class-ref in PlayerViewController.o
"_OBJC_CLASS_$_Song", referenced from:
objc-class-ref in PlayerViewController.o
"_currentIndex", referenced from:
-[PlayerViewController viewDidLoad] in PlayerViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
关于如何解决这个问题的任何提示?
我试图将SDL_mixer,SDL_ttf和SDL_image链接到我的项目,但由于某种原因,在编译我的代码时会弹出这些错误.我包含的头文件取决于它上面的库.我按此顺序链接到我的库:
MinGW32 OpenGL32 SDLmain SDL SDL_image SDL_ttf SDL_mixer
#include <map>
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
#include <GL/gl.h>
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL_ttf.h>
using namespace std;
#include "include_file.h"
#include "structure.h"
#include "player.h"
#include "healthclass.h"
#include "items.h"
#include "loadfiles.h"
#include "init_game.h"
#include "missions.h"
Run Code Online (Sandbox Code Playgroud)
那么错误:
obj\Release\main.o:main.cpp:(.text+0x16e): undefined reference to `Mix_LoadMUS'
obj\Release\main.o:main.cpp:(.text+0x197): undefined reference to `Mix_LoadWAV_RW'
obj\Release\main.o:main.cpp:(.text+0x1c0): undefined reference to `Mix_LoadWAV_RW'
obj\Release\main.o:main.cpp:(.text+0x1e9): undefined reference to `Mix_LoadWAV_RW'
obj\Release\main.o:main.cpp:(.text+0x7cd): undefined reference to `IMG_Load'
obj\Release\main.o:main.cpp:(.text+0x996): undefined reference to `TTF_RenderUTF8_Shaded' …Run Code Online (Sandbox Code Playgroud) 我正在开发一款带有ARC的cocos2d的游戏.游戏在模拟器中构建和运行良好,但是当我构建设备时,我得到了Apple Mac-O Linker Errors,说我错过了libcocos2d.a等的库.
clang: error: no such file or directory: '/Users/aleksandartrpeski/Library/Developer/Xcode/DerivedData/jellyfish-fsomqwhqasishxcfzhgvccrdvzpt/Build/Products/Debug-iphoneos/libcocos2d.a'
clang: error: no such file or directory: '/Users/aleksandartrpeski/Library/Developer/Xcode/DerivedData/jellyfish-fsomqwhqasishxcfzhgvccrdvzpt/Build/Products/Debug-iphoneos/libCocosDenshion.a'
clang: error: no such file or directory: '/Users/aleksandartrpeski/Library/Developer/Xcode/DerivedData/jellyfish-fsomqwhqasishxcfzhgvccrdvzpt/Build/Products/Debug-iphoneos/libkazmath.a'
clang: error: no such file or directory: '/Users/aleksandartrpeski/Library/Developer/Xcode/DerivedData/jellyfish-fsomqwhqasishxcfzhgvccrdvzpt/Build/Products/Debug-iphoneos/liblibpng.a'
Run Code Online (Sandbox Code Playgroud)
当我去文件丢失的文件夹时,我只看到了jellyfish.app.
我在这类问题上没有多少经验,我不清楚为什么会这样,我检查了如何从TinyTimGames和LearnCocos2D启动项目,仍然不清楚我做错了什么.
xcode mach-o linker-errors cocos2d-iphone automatic-ref-counting
#define no_cust 4000
#define no_plant 50
#define no_sup 2000
#define No_population 100
#define Iteration 3
struct Output2{
long double RandomZhj[No_population];
double Population[No_population];
long double result;
long double cost_sup_to_plant;
long double velocity[No_population];
}Zhj[no_sup][no_plant],Whj[no_sup][no_plant],Vhj_t1[no_sup][no_plant];
Run Code Online (Sandbox Code Playgroud)
当我运行程序时,它显示:
致命错误LNK1248:图像尺寸(818D4000)超出最大允许尺寸(80000000)
我想知道如何更正我的程序.
我刚接触C++编程,但有一些Java经验.我创建了一个非常基本的类Dog.cpp及其头文件Dog.hpp.Netbeans不会构建项目,给我一个错误,说明构造函数和getAge函数的多个定义.就我而言,我已经在头文件中声明了构造函数和函数,并在类文件中定义它们.我哪里出错了?
提前致谢!
Dog.hpp:
#include <iostream>
using namespace std;
class Dog
{
public:
Dog(int someAge); // Constructor
~Dog(); // Destructor
int getAge() const; // function prototype
private:
int itsAge; // age variable
};
Run Code Online (Sandbox Code Playgroud)
Dog.cpp:
#include "Dog.hpp"
using namespace std;
Dog::Dog(int anAge)
{
cout << "Dog created \n";
}
int Dog::getAge() const
{
return itsAge;
}
Run Code Online (Sandbox Code Playgroud)
**main.cpp
#include <iostream>
#include "Dog.cpp"
int main()
{
Dog aDog(5);
cout << aDog.getAge();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
Netbeans输出:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory …Run Code Online (Sandbox Code Playgroud) 我对iOS开发比较陌生.我不知道如何解决以下我认为引用蓝牙库的错误.我该怎么做才能调试/解决这个问题?
架构armv7的未定义符号:"_CBCentralManagerScanOptionAllowDuplicatesKey",引用自:libnCLiOS.a(nclCb.o)中的_nclSStartScan"_CBAdvertisementDataManufacturerDataKey",引用自: - [Boss centralManager:didDiscoverPeripheral:advertisementData:RSSI:] in libNCLiOS.a(nclCb.o )"_ OBJC_CLASS _ $ _ CBUUID",引自:libnCLiOS.a中的objc-class-ref(nclCb.o)"_ OBJC_CLASS _ $ _ CBCentralManager",引自:libNCLiOS.a中的objc-class-ref(nclCb.o)ld:symbol (s)找不到架构armv7 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)
我正在尝试将Firebase Messaging添加到我的iOS项目中.我无法使用Pod,因为我的Developermachine会破坏它们.所以我手动添加框架.正如自述文件所述,我将分析和消息文件夹的所有框架以及Firebase.h添加到我的Xcode项目中.我添加了其他Stackoverflow问题中提到的Storekit.framework,libz,libc ++和libsqlite3.0,以消除大多数链接器错误.但由于以下错误,我仍然无法编译/链接我的项目:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_SKPaymentQueue", referenced from:
objc-class-ref in FirebaseAnalytics(FIRAInAppPurchaseTransactionReporter_ca1fe3eb82b823d5f96d3f8b4baedc9c.o)
"_OBJC_CLASS_$_SKProductsRequest", referenced from:
objc-class-ref in FirebaseAnalytics(FIRAProductsRequest_8f770071350872416d311668917f3a41.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
我不明白为什么他们会丢失或者我需要添加哪个库来进行此操作.有人知道该怎么办吗?
我还应该提到我在这个项目上使用Qt.
提前致谢,
objective-c linker-errors ios firebase firebase-cloud-messaging
linker-errors ×10
c++ ×5
ios ×2
xcode ×2
bluetooth ×1
boost ×1
c ×1
codeblocks ×1
firebase ×1
ios5 ×1
mach-o ×1
max ×1
mingw ×1
objective-c ×1
sdl ×1
ubuntu-10.04 ×1