Closed intractabilis closed 3 years ago
Hi, you may want to share your building/linking setup and/or files, templates in C++ files are usually not an issue and allow for faster development/rebuild.
Building and linking of the library is as described in README.md
. Toolset is GCC 11. Linking with the library uses your libcmaes.pc
.
All of this is irrelevant. Templates must be defined in header files, period.
allow for faster development/rebuild
How so if it doesn't work? I'd rather spend a couple of extra seconds of compilation than hours of search what explicit templates I have to instantiate and then recompile the library, or moving definitions to the header files. Nobody does it in a bizarre way you have done it.
If you would like to shorten your compilation time for development purposes, use precompiled header files. I recommend Meson for that. Setting up a precompiled header is one liner in Meson.
Another thing: don't enforce C++11 in libcmaes.pc
. It's an ancient standard, most people use C++14 or C++17 nowadays.
All of this is irrelevant. Templates must be defined in header files, period.
This sounds nice :)
If you feel like marking your point by providing a PR, feel free. Until then, we do prefer action over reaction.
If you feel like marking your point by providing a PR, feel free. Until then, we do prefer action over reaction.
Good to know. Some people don't like others touch their code. I will revamp the whole library. I hope you won't complain on a lot of changes.
It's kind of a very basic C++ rule of thumb. If you define your template functions in C++ files included into a library, there is a guarantee it's not going to work, because the compiler doesn't know how to instantiate the templates.
Surely it doesn't work with your library too. Follow your build instructions, then try to compile and link with your library your own example:
You will see a multitude of link errors:
You must define template functions in header files, NEVER in C++ files.