链接器不构造用户定义的类型

时间:2012-09-08 09:17:57

标签: c++ eclipse linker

我有一个长期的项目,包括建立一个可以产生新颖的音乐和声的专家系统。我从VB.net开始到目前为止接受了这个项目,但是想使用一种独立于平台的语言,所以我转而使用c ++来促进未来的迁移。基本上音调是当被分组为矢量时形成和弦进行的一部分的原子,当被分组为矢量时形成块的一部分等。因此整个结构具有递归感觉。虽然以下代码将在Netbeans 7.2中进行编译和链接,但我遇到了很难解决的内存问题,所以我现在正在使用Eclipse。虽然动态库将在Eclipse中编译,但似乎在总体级别上存在链接问题,从而不会创建对象。我花了几天时间尝试各种补救措施。我在这里包括顶级主要代码和我收到的错误消息的部分列表。任何有关可能发生的事情的指示都将受到赞赏。 Thx在期待..

/* 
 * File:   main.cpp
 * Author: Creative
 *
 * Created on August 6, 2012, 10:49 AM
 */

#include "../tonestatdynlib/name_pitchstructure.h"
#include "../sequencerdynlib/chord.h"
#include "../sequencerdynlib/Move.h"
#include "../sequencerdynlib/block.h"
#include "../sequencerdynlib/prog.h"
#include "../legalitydynlib/testLegal.h"
#include "../dataWriterdynlib/dWriter.h"
#include <iostream>
#include <sqlite3.h>//database facility

int main(int argc, char** argv) {

    int make;
    char start;

    cout << "Do you want to start a new movement? Y/N" << endl;

cin >> start;

    if (start == 'Y') {
        bool end = false;
        Move theMove;
        block theBlock;
        prog theProg;
        int i = 1, mv = 1, bk = 1, pr = 1;

        theMove.items.push_back(theBlock);
        theBlock.items.push_back(theProg);

        do {
            chord nextChord(i);
            nextChord.getPitches();
            theProg.items.push_back(nextChord);
            dWriter dW(nextChord, pr, bk, mv, "SONO");
            cout << "Chord Number " << i << " is completed. Do you want to:" << endl;
            cout << "Enter another chord?:  1" << endl;
            cout << "Start a new progression?: 2" << endl;
            cout << "Start a new block?: 3" << endl;
            cout << "Start a new movement?: 4" << endl;
            cout << "Exit SONO: 5" << endl;
            cin >> make;
            switch (make) {
                case 5: end = true;
                    break;
                case 1: i++;
                    break;
                case 2: i = 1;
                    pr++;
                    break;
                case 3: i = 1;
                    pr = 1;
                    bk++;
                    break;
                case 4: i = 1;
                    pr = 1;
                    bk = 1;
                    mv++;
                    break;
            }
        } while (end == false);
    }
    return 0;
}

错误讯息:

g++ -L"/Users/Creative/Documents/workspace/tonestatdynlib/Debug" -L"/Users/Creative/Documents/workspace/chordOpsdynlib/Debug" -L"/Users/Creative/Documents/workspace/dataWriterdynlib/Debug" -L"/Users/Creative/Documents/workspace/legalitydynlib/Debug" -L"/Users/Creative/Documents/workspace/sequencerdynlib/Debug" -L"/Users/Creative/Documents/workspace/tonestatdynlib" -L"/Users/Creative/Documents/workspace/sequencerdynlib" -L"/Users/Creative/Documents/workspace/legalitydynlib" -L"/Users/Creative/Documents/workspace/dataWriterdynlib" -L"/Users/Creative/Documents/workspace/chordOpsdynlib" -o "SONO"  ./main.o  



Undefined symbols for architecture x86_64:
  "block::block(block const&)", referenced from:
      __gnu_cxx::new_allocator<block>::construct(block*, block const&)in main.o
      void std::_Construct<block, block>(block*, block const&)in main.o
      std::vector<block, std::allocator<block> >::_M_insert_aux(__gnu_cxx::__normal_iterator<block*, std::vector<block, std::allocator<block> > >, block const&)in main.o
  "prog::prog(prog const&)", referenced from:
      void std::_Construct<prog, prog>(prog*, prog const&)in main.o
      __gnu_cxx::new_allocator<prog>::construct(prog*, prog const&)in main.o
      std::vector<prog, std::allocator<prog> >::_M_insert_aux(__gnu_cxx::__normal_iterator<prog*, std::vector<prog, std::allocator<prog> > >, prog const&)in main.o
  "chord::chord(chord const&)", referenced from:
      void std::_Construct<chord, chord>(chord*, chord const&)in main.o
      __gnu_cxx::new_allocator<chord>::construct(chord*, chord const&)in main.o
      std::vector<chord, std::allocator<chord> >::_M_insert_aux(__gnu_cxx::__normal_iterator<chord*, std::vector<chord, std::allocator<chord> > >, chord const&)in main.o
  "pitchStats::pitchStats(pitchStats const&)", referenced from:
      void std::_Construct<pitchStats, pitchStats>(pitchStats*, pitchStats const&)in main.o
  "block::~block()", referenced from:
      _main in main.o
      std::vector<block, std::allocator<block> >::_M_insert_aux(__gnu_cxx::__normal_iterator<block*, std::vector<block, std::allocator<block> > >, block const&)in main.o
  "prog::~prog()", referenced from:
      _main in main.o
      std::vector<prog, std::allocator<prog> >::_M_insert_aux(__gnu_cxx::__normal_iterator<prog*, std::vector<prog, std::allocator<prog> > >, prog const&)in main.o
  "chord::~chord()", referenced from:
      _main in main.o
      std::vector<chord, std::allocator<chord> >::_M_insert_aux(__gnu_cxx::__normal_iterator<chord*, std::vector<chord, std::allocator<chord> > >, chord const&)in main.o
  "Move::Move()", referenced from:
      _main in main.o
  "block::block()", referenced from:
      _main in main.o
  "prog::prog()", referenced from:
      _main in main.o
  "chord::chord(int)", referenced from:
      _main in main.o
  "chord::getPitches()", referenced from:
      _main in main.o
  "dWriter::dWriter(chord const&, int, int, int, char const*)", referenced from:
      _main in main.o
  "dWriter::~dWriter()", referenced from:
      _main in main.o
  "Move::~Move()", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [SONO] Error 1

1 个答案:

答案 0 :(得分:2)

您只提供搜索要链接的库的路径。您还需要使用-l提供库。例如,libFoo.so使用-lFoo