Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
On Wed, 26 Jun 2019, Roumen Petrov wrote: but this is error-prone because some other toolchains might use a different C++ library. Oracle Solaris 11 with the Solaris Studio 12 compiler supports a large number of C++ runtime libraries as described at https://docs.oracle.com/cd/E37069_01/html/E37075/bkaje.html When dealing with C++, one must know what one is doing. The only portable way to link with C++ is by assuring that the main() function is in a C++ module. If the C++ compiler is intentionally used to link using the other options supplied to the compiler, then the correct libraries will be automatically selected by the compiler. On a typical GNU Linux or FreeBSD system, all C++ software is built using the same C++ runtime libraries (at some specified C++ standard level). This is accomplished through brute force by the OS package maintainers. Bob -- Bob Friesenhahn bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer,http://www.GraphicsMagick.org/ Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt ___ https://lists.gnu.org/mailman/listinfo/libtool
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
uri wrote: > On 2019-06-24 09:55, Roumen Petrov wrote: >> >> And projects builds just fine! >> Conclusion - there is no defect neither in libtool nor in automake nor >> in project autotool files. >> >> Reporter still does not provide feedback with information from >> configuration time (requested in a previous post) => resolution is - >> broken build environment. > > > configure and Makefile.in contain -lstdc++. These could be different > between systems. On FreeBSD it should be -lc++. Both configure and Makefile.in are generated . You cannot blame configure for -lstdc++ as more or less is expected. It depend from so many things. For instance is normal a autoconf based project to check for function or libraries. Next is Makefile.in. It is generated from Makefile.am. Please check again ;). > > It worked when I patched these lines, Dunno why you shut in the dark. but this is error-prone because > some other toolchains might use a different C++ library. Yes , and instead to update generated scripts you could help project ViennaRNA to improve build with correct report. > > > Once the error-prone -lstdc++ are removed, libtool fails because it > links with the C compiler. Ha-ha. Interesting. Now I have idea how broke your build system . Please avoid to update randomly some scripts. One again ViennaRNA build fine in my environment. Build system uses proper compiler. NO ISSUE WITH LIBTOOL! > Yuri Regards, Roumen ___ https://lists.gnu.org/mailman/listinfo/libtool
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
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
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
On Mon, 24 Jun 2019, Roumen Petrov wrote: Reporter still does not provide feedback with information from configuration time (requested in a previous post) => resolution is - broken build environment. I think the problem is an unreasonable expectation which is becoming more unreasonable as time goes by. C++ supports exceptions and C does not. If the run-time used does not provide an exception handling framework then there will be a core dump either when the C++ exception is initially thrown, or at the boundary of C/C++. Bob -- Bob Friesenhahn bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer,http://www.GraphicsMagick.org/ Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt ___ https://lists.gnu.org/mailman/listinfo/libtool
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
On 2019-06-24 09:55, Roumen Petrov wrote: And projects builds just fine! Conclusion - there is no defect neither in libtool nor in automake nor in project autotool files. Reporter still does not provide feedback with information from configuration time (requested in a previous post) => resolution is - broken build environment. configure and Makefile.in contain -lstdc++. These could be different between systems. On FreeBSD it should be -lc++. It worked when I patched these lines, but this is error-prone because some other toolchains might use a different C++ library. Once the error-prone -lstdc++ are removed, libtool fails because it links with the C compiler. Yuri ___ https://lists.gnu.org/mailman/listinfo/libtool
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
Dunno what is wrong in Yuri's FreeBSD environment Bob Friesenhahn wrote: On Sun, 23 Jun 2019, Yuri wrote: So is there an easy way to override this and always use C++ way of linking? To do this you might need to set LD or CC to your C++ compiler. A better way is to make your main program be C++ since that assures it can work. Consider that C++ exceptions can not be thrown into C code unless a special compiler option is used so that C supports the exception framework. Without this you are likely to get a core dump. C++ is very good at using C code but C code is not very good at using C++ code. Bob In my environment /usr/bin/cc is link to gcc , linked to gcc-5.5.0, and c++ is linked to g++, linked to g++-gcc-5.5.0. In my environment. At configure time both compiles are detected as usable. At build time I could see: - for C code: CC foo CCLD bar - for C++ code: CXX alice CXXLD bob And projects builds just fine! Conclusion - there is no defect neither in libtool nor in automake nor in project autotool files. Reporter still does not provide feedback with information from configuration time (requested in a previous post) => resolution is - broken build environment. Regards, Roumen ___ https://lists.gnu.org/mailman/listinfo/libtool
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
On Sun, 23 Jun 2019, Yuri wrote: So is there an easy way to override this and always use C++ way of linking? To do this you might need to set LD or CC to your C++ compiler. A better way is to make your main program be C++ since that assures it can work. Consider that C++ exceptions can not be thrown into C code unless a special compiler option is used so that C supports the exception framework. Without this you are likely to get a core dump. C++ is very good at using C code but C code is not very good at using C++ code. Bob -- Bob Friesenhahn bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer,http://www.GraphicsMagick.org/ Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt ___ https://lists.gnu.org/mailman/listinfo/libtool
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
On 2019-06-23 17:29, Bob Friesenhahn wrote: I doubt that libtool can be smart enough to intuit when the C++ compiler needs to be used for linking when the program being linked is C. The only way it could tell this is via library dependencies. Just supplying the library dependencies is not enough. C++ introduces a new wrinkle in that there are now often 3 or 4 different C++ variants available based on C++ standard level, and library options (e.g. different C++ STL library implementations). Things have changed quite a lot in the past several years when it comes to C++. In addition to being linked using the C++ compiler, the correct options would need to be passed to the C++ compiler so that the correct standard level and libraries are used. So is there an easy way to override this and always use C++ way of linking? Yuri ___ https://lists.gnu.org/mailman/listinfo/libtool
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
On Sun, 23 Jun 2019, Yuri wrote: Those variables could be used to tune build process. For instance CXX=my-c++ ./configure ... could be used to change C++ compiler. It seems to know that c++ is the C++ compiler, but then uses cc anyway: I doubt that libtool can be smart enough to intuit when the C++ compiler needs to be used for linking when the program being linked is C. The only way it could tell this is via library dependencies. Just supplying the library dependencies is not enough. C++ introduces a new wrinkle in that there are now often 3 or 4 different C++ variants available based on C++ standard level, and library options (e.g. different C++ STL library implementations). Things have changed quite a lot in the past several years when it comes to C++. In addition to being linked using the C++ compiler, the correct options would need to be passed to the C++ compiler so that the correct standard level and libraries are used. Bob -- Bob Friesenhahn bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer,http://www.GraphicsMagick.org/ Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt ___ https://lists.gnu.org/mailman/listinfo/libtool
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
On 2019-06-23 12:45, Roumen Petrov wrote: If clang is default OS compiler is expected symbolic link c++ to clang++ or similar. May be some OS setup commands could set such links. Remark: At end ./configure --help outputs environment variables . Those variables could be used to tune build process. For instance CXX=my-c++ ./configure ... could be used to change C++ compiler. It seems to know that c++ is the C++ compiler, but then uses cc anyway: https://people.freebsd.org/~yuri/vienna.log Yuri ___ https://lists.gnu.org/mailman/listinfo/libtool
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
Yuri wrote: On 2019-06-23 12:19, Roumen Petrov wrote: cc ? I'm not sure which compiler suite is used on FreeBSD but it seems to me C++ compiler is not installed. clang8 is used. cc is a C compiler, c++ is a C++ compiler. Ok. Dunno why is not detected c++ at configure time. I'm not familiar with clang as C++ compiler, especially installed symbolic links. Please check configure output and then config.log to find why detection(tests) for C++ compiler fail. Also check detection of C complier. For instance autoconf macro should search for availability of g++ or c++ or cxx or CC and etc as C++ compiler commands. If clang C++ is not in list detection fail. If clang is default OS compiler is expected symbolic link c++ to clang++ or similar. May be some OS setup commands could set such links. Remark: At end ./configure --help outputs environment variables . Those variables could be used to tune build process. For instance CXX=my-c++ ./configure ... could be used to change C++ compiler. Roumen ___ https://lists.gnu.org/mailman/listinfo/libtool
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
On 2019-06-23 12:19, Roumen Petrov wrote: cc ? I'm not sure which compiler suite is used on FreeBSD but it seems to me C++ compiler is not installed. clang8 is used. cc is a C compiler, c++ is a C++ compiler. Yuri ___ https://lists.gnu.org/mailman/listinfo/libtool
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
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 cc ? I'm not sure which compiler suite is used on FreeBSD but it seems to me C++ compiler is not installed. Roumen ___ https://lists.gnu.org/mailman/listinfo/libtool
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
On 2019-06-23 12:06, Bob Friesenhahn wrote: Are you using expected file extensions for C++ code? Is your main program a C++ module or a C module? C++ code uses .cpp extension. main programs are all in .c files. Yuri ___ https://lists.gnu.org/mailman/listinfo/libtool
Re: libtool uses cc to link a mixed C/C++ project and fails to find operator new
On Sun, 23 Jun 2019, Yuri wrote: On FreeBSD libtool can't find operator new[] because it is in C mode: How to switch libtool to the C++ mode? Are you using expected file extensions for C++ code? Is your main program a C++ module or a C module? Bob -- Bob Friesenhahn bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer,http://www.GraphicsMagick.org/ Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt ___ https://lists.gnu.org/mailman/listinfo/libtool