SORU
26 Mayıs 2012, CUMARTESİ


Linker verir "tehcir sembol dizini geçersiz bir sembol vardır..."

Ubuntu üzerinde bazı kod çalışıyorum. Aşağıdaki kod çalıştırmak için çalışıyorum

#include <cstdlib>
#include <cmath>
#include <ctime>
#include "random.h"

using namespace std;

/* Function prototype! */
void initRandomSeed();

int randomInteger(int low,int high){
    initRandomSeed();
    double d= rand()/(double(RAND_MAX) 1);
    double s= d*(double(high)-low 1);
    return int(floor(low) s);    
}

double  randomReal(int low,int high){
    initRandomSeed();
    double d=rand()/(double(RAND_MAX) 1);
    double s=d*(double(high)-low 1);
    return low s;
}    

bool randomChance(double p){
    initRandomSeed();
    return randomReal(0,1)<p;
}            

void setRandomSeed(int seed){    
    initRandomSeed();
    srand(seed);
}    

void initRandomSeed(){
    // to retain updated values across different stack frames! nice!
    static bool initialized=false;

    // this is executed only very first time and random value obtained from system clock!
    if(!initialized){
        srand(int(time(NULL)));
        initialized=true;
    }
}

Ve yukarıdaki kodu kullanarak derlemeye çalıştığımda g aşağıdaki hatayı alıyorum

@ubuntu:~/Chardway$ g   random.cpp
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 10
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 10
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 20 has invalid symbol index 19
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text 0x20): undefined reference to `main'
collect2: ld returned 1 exit status

Herhangi bir yardım veya yardıma gerçekten yardımcı olabilecek sorular bağlantılar! Teşekkürler!

CEVAP
26 Mayıs 2012, CUMARTESİ


Geçersiz yerleştirme Hataları konusunda emin değilim ama açık bir şey eksik main fonksiyon yok. Uygulamanız için bir giriş noktası olarak main, bu genel kapsamında tanımlanan adlı tanımlamak gerekir:

int main()
{
    // TODO: implementation
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • alex maybury

    alex maybury

    20 Aralık 2007
  • BgirlNilaya

    BgirlNilaya

    29 EKİM 2008
  • dope2111

    dope2111

    29 HAZİRAN 2009