| | |
Subtile link error
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
Hello, everyone! It's been a long time using C++ and I have a link problem.
This is the code...
The included file pcslib.h is:
There's a cpp file, pcsfile.cpp, that implements the public methods. When I'm passing the first block of code to the compiler (g++), I'm having this message and I don't know why. Can you help me?
Undefined first referenced
symbol in file
Pcs::Join() /var/tmp//ccsCx3jl.o
Pcs:: Pcs(char*) /var/tmp//ccsCx3jl.o
ld: fatal: Symbol referencing errors. No output written to loader
collect2: ld returned 1 exit status
This is the code...
C++ Syntax (Toggle Plain Text)
#include <iostream> #include "libc++/pcslib.h" int main() { std::cout << "About to load the server and all the clients." << std::endl; Pcs serverProcess("server"); Pcs clientProcess("client"); serverProcess.Join(); clientProcess.Join(); std::cout << "After joining with processes." << std::endl; return 0; }
The included file pcslib.h is:
C++ Syntax (Toggle Plain Text)
#include <unistd.h> #include <stdio.h> #include <iostream> #include <sys/wait.h> #include <signal.h> #include <errno.h> class Pcs { private: int pcsid; int status; public: Pcs(); Pcs(char *fichier); void Fork(char *fichier); int Join(); void Detruit(); };
There's a cpp file, pcsfile.cpp, that implements the public methods. When I'm passing the first block of code to the compiler (g++), I'm having this message and I don't know why. Can you help me?
Undefined first referenced
symbol in file
Pcs::Join() /var/tmp//ccsCx3jl.o
Pcs:: Pcs(char*) /var/tmp//ccsCx3jl.o
ld: fatal: Symbol referencing errors. No output written to loader
collect2: ld returned 1 exit status
•
•
Join Date: May 2008
Posts: 538
Reputation:
Solved Threads: 86
It looks like it compiled, so the symbol was defined enough for the compiler to recognize them.
The link process is where the actual executable is built. The linker needs to match up the symbol that your main calls with the actual implementation.
You should probably add the pcsfile.cpp to the g++ command line so that it will compile and the linker will look there for symbol definitions.
There are other ways to do it, but that looks the easiest based on your description.
The link process is where the actual executable is built. The linker needs to match up the symbol that your main calls with the actual implementation.
You should probably add the pcsfile.cpp to the g++ command line so that it will compile and the linker will look there for symbol definitions.
There are other ways to do it, but that looks the easiest based on your description.
Last edited by Murtan; Jul 29th, 2009 at 12:57 am.
![]() |
Similar Threads
- Link error...Pls! Help (C++)
- d-link error (Viruses, Spyware and other Nasties)
- LINK error (C++)
- I got a Link error 1181 with fresh code from source safe. (C++)
- Cannot Find Server or DNS Error (Viruses, Spyware and other Nasties)
- Debugging Link errors (C)
- IE6 Problem Username/Password Link Error (Web Browsers)
Other Threads in the C++ Forum
- Previous Thread: Class Fraction...Need a code
- Next Thread: Question about graphics and to check a file location
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





