我正在使用 XCode 3.2 在 MacOS X 10.6 上编译一个简单的 wxWidgets 应用程序
链接器返回关于符号_main被定义两次的错误:
在我注释掉宏之后:
Implement_App(TestApp)
Run Code Online (Sandbox Code Playgroud)
错误消失了,编译并链接,我能够运行应用程序。
我还没有在任何地方找到这个,所以对此有什么想法吗?
我修改了Visual C++应用程序中的现有类,使其成为泛型类.该类由另外两个模块使用.当我单独编译这些模块时,一切正常.但是,当我执行Build All时,我会收到以下链接器错误:
1>Linking...
1> Creating library C:\ccmdb\prep\g3_v5.3\g3_tools\fc_tools\ZFRTool\ZStackMTI\Debug\ZStackMTI.lib and object C:\ccmdb\prep\g3_v5.3\g3_tools\fc_tools\ZFRTool\ZStackMTI\Debug\ZStackMTI.exp
1>SerialPort.obj : error LNK2019: unresolved external symbol "public: __thiscall CRingBuffer<unsigned char>::CRingBuffer<unsigned char>(unsigned long)" (??0?$CRingBuffer@E@@QAE@K@Z) referenced in function "public: __thiscall CSerialPort::CSerialPort(void)" (??0CSerialPort@@QAE@XZ)
1>ZStackMTI.obj : error LNK2001: unresolved external symbol "public: __thiscall CRingBuffer<unsigned char>::CRingBuffer<unsigned char>(unsigned long)" (??0?$CRingBuffer@E@@QAE@K@Z)
1>SerialPort.obj : error LNK2019: unresolved external symbol "public: __thiscall CRingBuffer<unsigned char>::~CRingBuffer<unsigned char>(void)" (??1?$CRingBuffer@E@@QAE@XZ) referenced in function "public: void * __thiscall CRingBuffer<unsigned char>::`scalar deleting destructor'(unsigned int)" (??_G?$CRingBuffer@E@@QAEPAXI@Z)
1>ZStackMTI.obj : error LNK2001: unresolved external symbol "public: …Run Code Online (Sandbox Code Playgroud) 我本周首次尝试建立公司iOS库/框架,遵循此博客文章中的步骤.
由于超出此问题的原因,我只能在为设备构建而不是为模拟器建立链接.
但是,现在我收到一个非常奇怪的错误:
ld:架构armv7 clang的2个重复符号:错误:链接器命令失败,退出代码为1(使用-v查看调用)
有问题的线条表明:
重复符号_OBJC_CLASS _ $ _ iContactsGridCell in:/ Users/* /Desktop/Projects/contactservice/branch/ContactServicesClient/DerivedData/iContacts/Build/Intermediates/iContacts.build/Debug-iphoneos/iContacts-5.1.build/Objects-normal/armv7/ iContactsGridCell.o /Applications/Xcode.app/Contents/Developer/Library/Frameworks/athium-iOS.framework/athium-iOS重复符号_OBJC_METACLASS _ $ _ iContactsGridCell in:/ Users/*/Desktop/Projects/contactservice/branch/ContactServicesClient/DerivedData /iContacts/Build/Intermediates/iContacts.build/Debug-iphoneos/iContacts-5.1.build/Objects-normal/armv7/iContactsGridCell.o /Applications/Xcode.app/Contents/Developer/Library/Frameworks/athium-iOS.framework/athium-IOS
显然,有问题的类是iContactsGridCell.h
该类本身继承自Cell.h
@interface iContactsGridCell : Cell
Run Code Online (Sandbox Code Playgroud)
类Cell.h是框架的一部分,如果我不输入正确的文件,然后按预期我得到一个语义错误:无法找到电池接口声明等等等等.
但是,当我导入它时,我得到以下重复错误.除了iContactsGridCell.h之外,该文件不包含在项目的任何其他位置!
反过来,文件Cell.h只是在框架下找到的一个类:
@interface Cell : NSObject
@property (strong,nonatomic) UIView *view;
@property CGRect rect;
@property int UID;
@property BOOL highlighted;
@property UIColor *b_colr;
- (id) initWithRect:(CGRect)frame;
- (BOOL) hasCoordinates:(CGPoint)coord;
- (void) ripple;
- (void) cubefy;
- (void) flipfy;
- …Run Code Online (Sandbox Code Playgroud) 我正在尝试为CI设置我的第一个Bot.这个机器人成功地从git下载源代码树,但无法构建应用程序(IOS7,模拟器模式),我可以构建和运行它,而不会遇到常规的Xcode 5.0.1环境.
特别是Bot在ld阶段失败(参见下面的摘录).正如我可以从日志文件中建议的那样,ld找不到QuartzCore框架,其中定义了CA ..函数.
编译器从框架中找到了所有头文件,因此,对于第一眼看到的路径配置好了,但ld找不到库本身链接...
我怀疑这是一个关于权限或环境设置的微不足道的错误.你能指点我在哪里挖吗?
提前致谢.
此致,弗拉基米尔
+++ +++ +++
"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -L/Library/Server/Xcode/Data/BotRuns/Cache/c5e74f8f-f2c8-f2c8-9bba-cc3ce564b8fb/DerivedData/Build/Products/Debug-iphonesimulator -F/Library/Server/Xcode/Data/BotRuns/Cache/c5e74f8f-f2c8-f2c8-9bba-cc3ce564b8fb/DerivedData/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist /Library/Server/Xcode/Data/BotRuns/Cache/c5e74f8f-f2c8-f2c8-9bba-cc3ce564b8fb/DerivedData/Build/Intermediates/SBK.build/Debug-iphonesimulator/SBKTests.build/Objects-normal/i386/SBKTests.LinkFileList -bundle_loader /Library/Server/Xcode/Data/BotRuns/Cache/c5e74f8f-f2c8-f2c8-9bba-cc3ce564b8fb/DerivedData/Build/Products/Debug-iphonesimulator/SBK.app/SBK -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=6.1 -framework CoreText -framework SenTestingKit -framework UIKit -framework Foundation -framework CoreData -Xlinker -dependency_info -Xlinker /Library/Server/Xcode/Data/BotRuns/Cache/c5e74f8f-f2c8-f2c8-9bba-cc3ce564b8fb/DerivedData/Build/Intermediates/SBK.build/Debug-iphonesimulator/SBKTests.build/Objects-normal/i386/SBKTests_dependency_info.dat -o /Library/Server/Xcode/Data/BotRuns/Cache/c5e74f8f-f2c8-f2c8-9bba-cc3ce564b8fb/DerivedData/Build/Products/Debug-iphonesimulator/SBKTests.octest/SBKTests Undefined symbols for architecture i386:
"_CATransform3DMakeScale", referenced from: -[MBSwitch showFillLayer:animated:] in MBSwitch.o
"_CGAffineTransformIdentity", referenced from: -[TTTAttributedLabel drawTextInRect:] in TTTAttributedLabel.o
"_CGContextAddLineToPoint", referenced from: -[TTTAttributedLabel drawStrike:inRect:context:] in TTTAttributedLabel.o
"_CGContextAddPath", referenced from:
. …Run Code Online (Sandbox Code Playgroud) 我有一个带有命名空间的头文件,在该命名空间中我声明了几个事件和一个函数。在相应的 .cpp 文件中,我充实了赋予这些对象属性的函数(对象是联合)。然而,当我编译链接器声称对象已经在 main.obj 中声明时,它们还没有。我觉得这是我使用命名空间的问题,但我找不到任何指向该假设的内容。
.h
#pragma once
#include <SDL.h>
namespace UserEvents {
/*Events for the StateMachine*/
SDL_Event switchToEntryState;
SDL_Event switchToIntroState;
SDL_Event switchToGameState;
SDL_Event switchToPauseState;
SDL_Event exitState;
SDL_Event shutdownStateMachine;
bool initUserStates();
};
Run Code Online (Sandbox Code Playgroud)
和 .cpp
#include "UserEvents.h"
using namespace UserEvents;
/*
SDL_Event switchToEntryState;
SDL_Event switchToIntroState;
SDL_Event switchToGameState;
SDL_Event switchToPauseState;
SDL_Event exitState;
SDL_Event shutdownStateMachine;
*/
/*
***********************************
USER EVENT CODE CHART
***********************************
EVENT CODE | MODULE
--------------------
0 | STATEMACHINE
*/
bool initUserStates() {
//Attempt to register the number of events
Uint32 …Run Code Online (Sandbox Code Playgroud) 我在 VS2017 的项目编译过程中遇到以下问题:
1>libPolyFill.lib(libPolyFill.obj):错误 LNK2038:检测到“_MSC_VER”不匹配:值“1800”与 clientPolyFill.obj 中的值“1900”不匹配
项目中包含的库文件是在 VS2013 中编译的,所以我知道我需要一个特定的平台工具集 (V120) 来编译它。但问题是,即使在微软网站上,Toolset V120 也不再可用。 我只有这个工具集平台可供选择 在这种情况下我能做什么?感谢帮助!
我正在尝试为我的项目编写Makefile.这是文件结构:
Makefile文件:
CXXFLAGS = -ISDL2/include -std=c++11
LXXFLAGS = -lSDL2/lib/x86 -lSDL2main -lSDL2 -lSDL2_image
main.exe: main.o BoardField.o ChessPiece.o Game.o
g++ main.o BoardField.o ChessPiece.o Game.o -o main.exe $(LXXFLAGS) -std=c++11
main.o: main.cpp
g++ main.cpp -c $(CXXFLAGS)
BoardField.o: BoardField.cpp
g++ BoardField.cpp -c $(CXXFLAGS)
ChessPiece.o: ChessPiece.cpp
g++ ChessPiece.cpp -c $(CXXFLAGS)
Game.o: Game.cpp
g++ Game.cpp -c $(CXXFLAGS)
Run Code Online (Sandbox Code Playgroud)
我收到这些错误:
g ++ main.o BoardField.o ChessPiece.o Game.o -o main.exe -lSDL2/lib/x86 -lSDL2main -lSDL2 -lSDL2_image -std = c ++ 11 c:/ mingw/bin /../ lib/gcc /mingw32/6.3.0/../../../../mingw32/bin/ld.exe:找不到-lSDL2/lib/x86 c:/ mingw/bin /../ lib/gcc/mingw32 /6.3.0/../../../../mingw32/bin/ld.exe:找不到-lSDL2main c:/ mingw/bin …
我正在读《 c ++的完整指南》这本书。我认为第252页有错字。因此,我有以下三个文件。
在文件account.h中,
// account.h
// Defining the class Account. class definition (methods prototypes) is usually put in the header file
// ---------------------------------------------------
#ifndef _ACCOUNT_ // if _ACCOUNT_ is not defined
#define _ACCOUNT_
#include <iostream>
#include <string>
using namespace std;
class Account
{
private:
string name;
unsigned long nr;
double balance;
public: //Public interface:
bool init( const string&, unsigned long, double);
void display();
};
#endif
// _ACCOUNT_
Run Code Online (Sandbox Code Playgroud)
在account.cpp文件中,
// account.cpp
// Defines methods init() and display().
// ---------------------------------------------------
#include …Run Code Online (Sandbox Code Playgroud) 这是在utils.hpp(NON OOP,所以不在任何类中)定义的函数原型声明
static void create_xy_table(const k4a_calibration_t *calibration, k4a_image_t xy_table);
static void generate_point_cloud(const k4a_image_t depth_image,
const k4a_image_t xy_table,
k4a_image_t point_cloud,
int *point_count);
static void write_point_cloud(const char *file_name, const k4a_image_t point_cloud, int point_count);
Run Code Online (Sandbox Code Playgroud)
我对它们的定义utils.cpp包括utils.hpp。
当我使用中的函数调用任何main函数时main.cpp,出现以下错误:
/tmp/ccFcMfYB.o: In function `main':
main.cpp:(.text+0x208): undefined reference to
`create_xy_table(_k4a_calibration_t const*, _k4a_image_t*)
Run Code Online (Sandbox Code Playgroud)
编译命令:
g++ -o build/testtest src/main.cpp src/utils.cpp -I./include -lk4a
将所有函数都定义为非静态,并且可以完美地进行编译!!我无法解决这个问题。
我的系统配置:gcc版本7.4.0(Ubuntu 7.4.0-1ubuntu1〜18.04.1)
编辑:这是我在utils.cpp中的函数定义:
static void create_xy_table(const k4a_calibration_t *calibration, k4a_image_t xy_table)
{
k4a_float2_t *table_data …Run Code Online (Sandbox Code Playgroud) 谁能解释一下为什么是链接器错误?
假设该变量i未在任何其他文件中定义。
#include <stdio.h>
int main()
{
extern int i;
i=10;
printf("%d",i);
return 0;
}
Run Code Online (Sandbox Code Playgroud) linker-errors ×10
c++ ×7
g++ ×2
xcode ×2
c ×1
extern ×1
frameworks ×1
gcc ×1
generics ×1
linker ×1
makefile ×1
namespaces ×1
objective-c ×1
wxwidgets ×1