Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new

"John W. Eaton" <[email protected]>
Newsgroups gmane.comp.gnu.libtool.general
Message-ID <[email protected]>
On 6/23/19 2:56 PM, Yuri wrote:
> On FreeBSD libtool can't find operator new[] because it is in C mode:
> 
> libtool: link: cc -fno-strict-aliasing -fopenmp -ftree-vectorize 
> -pthread -O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong 
> -fno-strict-aliasing -fno-strict-aliasing -fstack-protector-strong -o 
> RNALfold RNALfold_cmdl.o RNALfold.o 
> ../../src/ViennaRNA/.libs/libRNA_conv.a ./.libs/libhelpers.a -lm 
> -pthread -fopenmp
> libtool: link: cc -fno-strict-aliasing -fopenmp -ftree-vectorize 
> -pthread -O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong 
> -fno-strict-aliasing -fno-strict-aliasing -fstack-protector-strong -o 
> RNALalifold RNALalifold_cmdl.o RNALalifold.o 
> ../../src/ViennaRNA/.libs/libRNA_conv.a ./.libs/libhelpers.a -lm 
> -pthread -fopenmp
> ld: error: undefined symbol: operator new[](unsigned long)
>  >>> referenced by svm.cpp
>  >>>               svm.o:(Kernel::Kernel(int, svm_node* const*, 
> svm_parameter const&)) in archive ../../src/ViennaRNA/.libs/libRNA_conv.a
> 
> 
> 
> I added "LT_LANG([C++]) to configure.ac but it didn't help:
> 
> AC_PROG_LIBTOOL
> LT_INIT([pic-only, static])
> LT_LANG([C++])
> AC_SUBST(LIBTOOL_DEPS)
> 
> 
> How to switch libtool to the C++ mode?

Are you using automake?  Or just libtool and autoconf?

With automake, the info at the end of the following section in the 
manual might help:

 
https://www.gnu.org/software/automake/manual/automake.html#Libtool-Convenience-Libraries

I think the same idea applies to executable files, not just building 
libraries from a collection of convenience libraries.  So (again, with 
automake) you can trick the system into using C++ for linking by having 
a C++ source file directly in the list of files to link.  That C++ 
source file doesn't have to contain anything or even exist.  Automake 
just notes that there is a C++ file in the list of files to link and 
uses the C++ linker.

jwe

_______________________________________________
https://lists.gnu.org/mailman/listinfo/libtool
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.