not being linked
From: Edo (eddod_at_eddododod.dod)
Date: 07/30/04
- Next message: Ben Cottrell: "Re: keywords"
- Previous message: .:'DevarajA':.: "keywords"
- Next in thread: Alwyn: "Re: not being linked"
- Reply: Alwyn: "Re: not being linked"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 30 Jul 2004 07:01:22 -0700
Hello
I am not sure why this code is giving error as below
Even though I have the util.h file under Project Options | Directories |
Include Directories and The library file util.a included in the
Parameters | Linker section in Dev-C++ with all updates.
thanks
/////////////////////////util.h/////////////////////////
#ifndef UTIL_H
#define UTIL_H
//util.h contains some usefull utility functions.
// to use it printElements(col, "all elements: ");
#include <iostream>
template <class T>
inline void printElements (const T& col, const char* pc="");
#endif
//////////////////////////printElements.cpp////////////////////////
//printElements.cpp
#include "util.h"
#include <iostream>
#include <iterator>
template <class T>
inline void printElements (const T& col, const char* pc="")
{
typename T::const_iterator pos;
std::cout << pc;
for (pos=col.begin(); pos!=col.end(); ++pos) {
std::cout << *pos << ' ';
}
std::cout << std::endl;
}
/////////////////////////////////////////////////////
the above 2 are compiled into util.a
/////////////////////////main.cpp///////////////////////
#include <iostream>
#include <vector>
#include "util.h"
using namespace std;
int main(){
vector<int> v1;
for(int i = 0; i < 9; ++i){
v1.push_back(i);
}
printElements(v1, "all: ");
cin.sync(); getchar(); return 0;
}
//////////////////////////////////////////////////////////
Compiler: Default compiler
Building Makefile: "C:\IBMDRV\C++\work\pract1\Makefile.win"
Executing make clean
rm -f main.o pract1.exe
g++.exe -D__DEBUG__ -c main.cpp -o main.o -I"C:/Dev-Cpp/include/c++"
-I"C:/Dev-Cpp/include/c++/mingw32" -I"C:/Dev-Cpp/include/c++/backward"
-I"C:/Dev-Cpp/include" -I"C:/IBMDRV/C++/work/util" -pg -g3
g++.exe -D__DEBUG__ main.o -o "pract1.exe" -L"C:/Dev-Cpp/lib"
../util/util.a -lgmon -pg -g3
main.o(.text+0xbb): In function `main':
C:/IBMDRV/C++/work/pract1/main.cpp:14: undefined reference to `void
printElements<std::vector<int, std::allocator<int> > >(std::vector<int,
std::allocator<int> > const&, char const*)'
make.exe: *** [pract1.exe] Error 1
Execution terminated
- Next message: Ben Cottrell: "Re: keywords"
- Previous message: .:'DevarajA':.: "keywords"
- Next in thread: Alwyn: "Re: not being linked"
- Reply: Alwyn: "Re: not being linked"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|