我有这个简单的代码:
max = (int) sqrt (number);
Run Code Online (Sandbox Code Playgroud)
在标题中我有:
#include <math.h>
Run Code Online (Sandbox Code Playgroud)
但应用程序仍然表示未定义的引用sqrt.你觉得这里有什么问题吗?看起来一切都应该没问题.
只是一个简单的程序,但我一直得到这个编译错误.我正在使用MinGW作为编译器.
这是头文件,point.h:
//type for a Cartesian point
typedef struct {
double x;
double y;
} Point;
Point create(double x, double y);
Point midpoint(Point p, Point q);
Run Code Online (Sandbox Code Playgroud)
这是重点.:
//This is the implementation of the point type
#include "point.h"
int main() {
return 0;
}
Point create(double x, double y) {
Point p;
p.x = x;
p.y = y;
return p;
}
Point midpoint(Point p, Point q) {
Point mid;
mid.x = (p.x + q.x) / 2;
mid.y …Run Code Online (Sandbox Code Playgroud) 我有一个带有常规目标和单元测试目标的XCode4/iOS项目.一切正常,除非我尝试#import我的测试类中的一个类并尝试使用它.如果我尝试构建单元测试目标,我会收到以下链接错误:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_FRRCategory", referenced from:
objc-class-ref in CategoryTests.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
在CategoryTests.m中,我以这种方式导入头文件:
#import "../todoro/FRRCategory.h"
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
几乎是最后一步,但仍然有一些奇怪的错误......
bash-3.2$ make
g++ -Wall -c -g Myworld.cc
g++ -Wall -g solvePlanningProblem.o Position.o AStarNode.o PRM.o PRMNode.o World.o SingleCircleWorld.o Myworld.o RECTANGLE.o CIRCLE.o -o solvePlanningProblem
Undefined symbols:
"vtable for Obstacle", referenced from:
Obstacle::Obstacle()in Myworld.o
"typeinfo for Obstacle", referenced from:
typeinfo for RECTANGLEin RECTANGLE.o
typeinfo for CIRCLEin CIRCLE.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [solvePlanningProblem] Error 1
Run Code Online (Sandbox Code Playgroud)
vtable和typeinfo的含义是什么?
我已经构建了我的应用程序(针对iOS7),现在想要在提交之前应用Google Analytics作为最后一步.我做了什么:
/GoogleAnalytics/Library/成组"Google分析"libGoogleAnalyticsServices.a群组"GoogleAnalytics"libGoogleAnalytics_debug.a与libGoogleAnalyticsServices.a#include "GAI.h"到我的-Prefix.pch文件.[GAI sharedInstance]我的AppDelegate.我在这篇文章的底部附上了设置的截图.当我尝试构建(设备或模拟器,32位)时,我得到以下链接器错误:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GAI", referenced from:
objc-class-ref in FTVAppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
更新1
我也得到了警告
ld: warning: ignoring file .../libGoogleAnalyticsServices.a, missing required architecture x86_64 in file .../libGoogleAnalyticsServices.a (3 slices)
ld: …Run Code Online (Sandbox Code Playgroud) 首先,我知道这个问题已经存在于整个网站上,但我已经看了几乎所有这些问题,似乎无法找出问题所在.这是在VS 2012.谢谢.
//Socket.h
#pragma once
#include <iostream>
#include <WinSock2.h>
using namespace std;
const int STRLEN = 256;
class Socket
{
protected:
WSADATA wsaData;
SOCKET mySocket;
SOCKET myBackup;
SOCKET acceptSocket;
sockaddr_in myAddress;
public:
Socket();
~Socket();
bool SendData( char* );
bool RecvData( char*, int );
void CloseConnection();
void GetAndSendMessage();
};
class ServerSocket : public Socket
{
public:
void Listen();
void Bind( int port );
void StartHosting( int port );
};
class ClientSocket : public Socket
{
public:
void ConnectToServer( const char *ipAddress, …Run Code Online (Sandbox Code Playgroud) 我定义了一个特殊文件: config.h
我的项目还有文件:
t.c, t.h
pp.c, pp.h
b.c b.h
l.cpp
Run Code Online (Sandbox Code Playgroud)
和#includes:
在tc:
#include "t.h"
#include "b.h"
#include "pp.h"
#include "config.h"
Run Code Online (Sandbox Code Playgroud)
在bc:
#include "b.h"
#include "pp.h"
Run Code Online (Sandbox Code Playgroud)
在pp.c:
#include "pp.h"
#include "config.h"
Run Code Online (Sandbox Code Playgroud)
在l.cpp中:
#include "pp.h"
#include "t.h"
#include "config.h"
Run Code Online (Sandbox Code Playgroud)
我的*.h文件中没有include指令,只在*.c文件中.我在config.h中定义了这个:
const char *names[i] =
{
"brian", "stefan", "steve"
};
Run Code Online (Sandbox Code Playgroud)
并在l.cpp,tc,pp.c中需要该数组但是我收到此错误:
pp.o:(.data+0x0): multiple definition of `names'
l.o:(.data+0x0): first defined here
t.o:(.data+0x0): multiple definition of `names'
l.o:(.data+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [link] Error …Run Code Online (Sandbox Code Playgroud) 我尝试在osx lion上编译这个cpp代码,但是我收到了一个错误.
#include <iostream>
using namespace std;
int main (int argc, char *argv[])
{
for(int i = 0; i < 10; i++)
{
cout << "hi";
cout << endl;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编译:
cc main.cpp
Run Code Online (Sandbox Code Playgroud)
错误:
Undefined symbols for architecture x86_64:
"std::cout", referenced from:
_main in ccBdbc76.o
"std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
_main in ccBdbc76.o
"std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
_main in ccBdbc76.o
"std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> …Run Code Online (Sandbox Code Playgroud) Ld /Users/pwang/Library/Developer/Xcode/DerivedData/socketiohldwxnslzhlnjtgihgewdwavpjpb/Build/Products/Debug-iphoneos/socketio.app/socketio normal armv7
cd /Users/pwang/Desktop/saturngod-Socket.io-with-iOS-be51414
setenv IPHONEOS_DEPLOYMENT_TARGET 4.3
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.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 armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -L/Users/pwang/Library/Developer/Xcode/DerivedData/socketio-hldwxnslzhlnjtgihgewdwavpjpb/Build/Products/Debug-iphoneos -L/Users/pwang/Desktop/saturngod-Socket.io-with-iOS-be51414/socketio/simulator -L/Users/pwang/Desktop/saturngod-Socket.io-with-iOS-be51414/socketio/device -F/Users/pwang/Library/Developer/Xcode/DerivedData/socketio-hldwxnslzhlnjtgihgewdwavpjpb/Build/Products/Debug-iphoneos -F/Users/pwang/Desktop/saturngod-Socket.io-with-iOS-be51414/socketio -filelist /Users/pwang/Library/Developer/Xcode/DerivedData/socketio-hldwxnslzhlnjtgihgewdwavpjpb/Build/Intermediates/socketio.build/Debug-iphoneos/socketio.build/Objects-normal/armv7/socketio.LinkFileList -dead_strip -lz -licucore -miphoneos-version-min=4.3 -framework MobileCoreServices -framework Foundation -lz -lxml2 -framework SystemConfiguration -framework CFNetwork -framework UIKit -framework CoreGraphics -o /Users/pwang/Library/Developer/Xcode/DerivedData/socketio-hldwxnslzhlnjtgihgewdwavpjpb/Build/Products/Debug-iphoneos/socketio.app/socketio
ld: warning: directory not found for option '-L/Users/pwang/Desktop/saturngod-Socket.io-with-iOS-be51414/socketio/simulator'
ld: warning: directory not found for option '-L/Users/pwang/Desktop/saturngod-Socket.io-with-iOS-be51414/socketio/device'
Run Code Online (Sandbox Code Playgroud)
你能给我一些删除警告的线索,谢谢.
linker-errors ×10
c++ ×4
c ×3
linker ×3
xcode ×2
cocoa-touch ×1
function ×1
ios ×1
ios5 ×1
macos ×1
ocunit ×1
pure-virtual ×1
unit-testing ×1
vtable ×1
xcode4 ×1