|
Re: How to link a static library in C++? [message #1716714 is a reply to message #1716628] |
Mon, 07 December 2015 16:54 |
David Vavra Messages: 1426 Registered: October 2012 |
Senior Member |
|
|
It's not a C++ thing. It depends on the linker being used.
Assuming you are using gcc (or g++) set the -static option in the command doing the linking.
For CDT, go to Project ==> Properties ==> C/C++ Build ==> Settings and add -static to the linker command. There may be a selection box for it, If not add it to the command.
Another option is to place the full name of the library in the command as if it were an object file and without the -l option.
GNU linker (ld) options:
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
Again, I am assuming GCC which is most likely. If you are using Visual Studio or others there are similar methods but you will need to consult their documentation.
[Updated on: Mon, 07 December 2015 17:08] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
Re: How to link a static library in C++? [message #1717065 is a reply to message #1717054] |
Wed, 09 December 2015 18:49 |
David Vavra Messages: 1426 Registered: October 2012 |
Senior Member |
|
|
Looks like it's a template function. You have to instantiate these somewhere.
Here's an example where I've instantiated Which<T> for STRING, int, UINT, float and double:
template<class T>
int Which(T val, const std::vector<T> & list);
template<class T>
int Which(const T nam, const std::vector<T> & list) {
for (UINT i=0; i<list.size(); i++) {
if (nam == list[i]) return i;
}
return -1;
}
template int Which(STRING, const std::vector<STRING> &);
template int Which(int, const std::vector<int> &);
template int Which(UINT, const std::vector<UINT> &);
template int Which(float, const std::vector<float> &);
template int Which(double, const std::vector<double> &);
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04525 seconds