标签: linker-errors

对sqrt(或其他数学函数)的未定义引用

我有这个简单的代码:

max = (int) sqrt (number);
Run Code Online (Sandbox Code Playgroud)

在标题中我有:

#include <math.h>
Run Code Online (Sandbox Code Playgroud)

但应用程序仍然表示未定义的引用sqrt.你觉得这里有什么问题吗?看起来一切都应该没问题.

c linker-errors undefined-reference

57
推荐指数
2
解决办法
9万
查看次数

C错误:未定义的函数引用,但它已定义

只是一个简单的程序,但我一直得到这个编译错误.我正在使用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)

c function linker-errors undefined-reference

55
推荐指数
3
解决办法
30万
查看次数

构建单元测试目标时链接错误

我有一个带有常规目标和单元测试目标的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)

我究竟做错了什么?

unit-testing linker-errors ocunit xcode4

52
推荐指数
3
解决办法
2万
查看次数

未定义的符号"vtable for ..."和"typeinfo for ..."?

几乎是最后一步,但仍然有一些奇怪的错误......

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的含义是什么?

c++ linker-errors pure-virtual vtable undefined-reference

46
推荐指数
5
解决办法
4万
查看次数

无法将GoogleAnalytics 3.01与XCode 5相关联(缺少必需的架构x86_64)

我已经构建了我的应用程序(针对iOS7),现在想要在提交之前应用Google Analytics作为最后一步.我做了什么:

  1. 下载了适用于iOS 3.01的GA
  2. 进口量/GoogleAnalytics/Library/成组"Google分析"
  3. 导入libGoogleAnalyticsServices.a群组"GoogleAnalytics"
  4. 新增建设阶段和交换构建阶段libGoogleAnalytics_debug.alibGoogleAnalyticsServices.a
  5. 添加了代码块#include "GAI.h"到我的-Prefix.pch文件.
  6. 初始化[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)

xcode cocoa-touch google-analytics linker-errors ios

46
推荐指数
3
解决办法
4万
查看次数

未解决的外部符号LNK2019

首先,我知道这个问题已经存在于整个网站上,但我已经看了几乎所有这些问题,似乎无法找出问题所在.这是在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)

c++ linker linker-errors unresolved-external visual-studio

43
推荐指数
2
解决办法
7万
查看次数

多个定义...链接器错误

我定义了一个特殊文件: 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)

c linker linker-errors

43
推荐指数
2
解决办法
10万
查看次数

编译一些简单的c ++代码时出错

我尝试在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)

c++ macos linker-errors

42
推荐指数
2
解决办法
5万
查看次数

MSVS编译器标志/ bigobj的惩罚

基本的Google搜索bigobj问题表明很多人都遇到致命错误C1128:" 部分数量超出了目标文件格式限制:用/ bigobj编译 ".如果大量使用C++模板(如Boost库CGAL库),则错误发生的可能性更大.

这个错误很奇怪,因为它为自己提供了解决方案:设置编译器标志/bigobj!

所以这是我的问题:为什么默认情况下不设置该标志?使用该标志必须有惩罚,否则默认设置.MSDN中没有记录该惩罚.有人有线索吗?

我问这个问题,因为我想知道CGAL的配置系统是否应该/bigobj默认设置.

c++ linker-errors visual-studio

42
推荐指数
2
解决办法
1万
查看次数

Xcode:警告:找不到选项的目录

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)

你能给我一些删除警告的线索,谢谢.

xcode linker linker-errors ios5

41
推荐指数
2
解决办法
4万
查看次数