[Interest] Link failure with undefined references, on Ubuntu but not macOS

Ben Haller bhaller at mac.com
Thu Apr 30 00:16:49 CEST 2020


Hi folks.  I’ve got a subdirs-type Qt Widgets project that lives here:

https://github.com/MesserLab/SLiM/tree/qtslim

(Note that’s the qtslim branch of a project named SLiM; the Qt stuff is all on the branch until I get it completely working.)

I build it with qmake and then make, with no further command-line flags.  I build it for two platforms: Linux (Ubuntu 18.04 LTS, specifically) and macOS (10.15.3).  In both cases I’m using Qt 5.14.2.

On Linux, but not on macOS, the build fails.  Here’s the link command:

g++ -Wl,-O1 -o QtSLiM main.o QtSLiMWindow.o QtSLiMAppDelegate.o QtSLiMWindow_glue.o QtSLiMChromosomeWidget.o QtSLiMExtras.o QtSLiMPopulationTable.o QtSLiMIndividualsWidget.o QtSLiMEidosPrettyprinter.o QtSLiMAbout.o QtSLiMPreferences.o QtSLiMSyntaxHighlighting.o QtSLiMFindRecipe.o QtSLiMHelpWindow.o QtSLiMScriptTextEdit.o QtSLiMEidosConsole.o QtSLiMEidosConsole_glue.o QtSLiMConsoleTextEdit.o QtSLiM_SLiMgui.o QtSLiMTablesDrawer.o QtSLiMFindPanel.o QtSLiMGraphView.o QtSLiMGraphView_FixationTimeHistogram.o QtSLiMGraphView_FrequencySpectra.o QtSLiMGraphView_LossTimeHistogram.o QtSLiMGraphView_PopulationVisualization.o QtSLiMGraphView_FitnessOverTime.o QtSLiMGraphView_FrequencyTrajectory.o QtSLiMHaplotypeManager.o QtSLiMHaplotypeOptions.o QtSLiMHaplotypeProgress.o QtSLiMVariableBrowser.o qrc_buttons.o qrc_icons.o qrc_recipes.o qrc_help.o moc_QtSLiMWindow.o moc_QtSLiMAppDelegate.o moc_QtSLiMChromosomeWidget.o moc_QtSLiMExtras.o moc_QtSLiMPopulationTable.o moc_QtSLiMIndividualsWidget.o moc_QtSLiMAbout.o moc_QtSLiMPreferences.o moc_QtSLiMSyntaxHighlighting.o moc_QtSLiMFindRecipe.o moc_QtSLiMHelpWindow.o moc_QtSLiMScriptTextEdit.o moc_QtSLiMEidosConsole.o moc_QtSLiMConsoleTextEdit.o moc_QtSLiMTablesDrawer.o moc_QtSLiMFindPanel.o moc_QtSLiMGraphView.o moc_QtSLiMGraphView_FixationTimeHistogram.o moc_QtSLiMGraphView_FrequencySpectra.o moc_QtSLiMGraphView_LossTimeHistogram.o moc_QtSLiMGraphView_PopulationVisualization.o moc_QtSLiMGraphView_FitnessOverTime.o moc_QtSLiMGraphView_FrequencyTrajectory.o moc_QtSLiMHaplotypeManager.o moc_QtSLiMHaplotypeOptions.o moc_QtSLiMHaplotypeProgress.o moc_QtSLiMVariableBrowser.o   -L/home/bhaller/Desktop/SLiM_QMAKE_5142/QtSLiM/../gsl/ -lgsl -L/home/bhaller/Desktop/SLiM_QMAKE_5142/QtSLiM/../eidos_zlib/ -leidos_zlib -L/home/bhaller/Desktop/SLiM_QMAKE_5142/QtSLiM/../eidos/ -leidos -L/home/bhaller/Desktop/SLiM_QMAKE_5142/QtSLiM/../core/ -lcore -L/home/bhaller/Desktop/SLiM_QMAKE_5142/QtSLiM/../treerec/tskit/ -ltskit -lQt5OpenGL -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread 

And here’s the beginning of the link errors, of which there are a fair number:

/home/bhaller/Desktop/SLiM_QMAKE_5142/QtSLiM/../eidos//libeidos.a(eidos_globals.o): In function `_Eidos_FlushZipBuffer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
eidos_globals.cpp:(.text+0x432): undefined reference to `z_gzopen'
eidos_globals.cpp:(.text+0x44f): undefined reference to `z_gzbuffer'
eidos_globals.cpp:(.text+0x461): undefined reference to `z_gzwrite'
eidos_globals.cpp:(.text+0x474): undefined reference to `z_gzclose_w'
/home/bhaller/Desktop/SLiM_QMAKE_5142/QtSLiM/../eidos//libeidos.a(eidos_globals.o): In function `Eidos_TTest_TwoSampleWelch(double const*, int, double const*, int, double*, double*)':
eidos_globals.cpp:(.text+0x3f99): undefined reference to `gsl_cdf_tdist_Q'
/home/bhaller/Desktop/SLiM_QMAKE_5142/QtSLiM/../eidos//libeidos.a(eidos_globals.o): In function `Eidos_TTest_OneSample(double const*, int, double, double*)':
eidos_globals.cpp:(.text+0x4195): undefined reference to `gsl_cdf_tdist_Q'
/home/bhaller/Desktop/SLiM_QMAKE_5142/QtSLiM/../core//libcore.a(chromosome.o): In function `Chromosome::~Chromosome()':
chromosome.cpp:(.text+0x3f): undefined reference to `gsl_ran_discrete_free'
chromosome.cpp:(.text+0x4d): undefined reference to `gsl_ran_discrete_free'
chromosome.cpp:(.text+0x5b): undefined reference to `gsl_ran_discrete_free'
chromosome.cpp:(.text+0x69): undefined reference to `gsl_ran_discrete_free'
chromosome.cpp:(.text+0x77): undefined reference to `gsl_ran_discrete_free’
…

The complete errors are listed in the GitHub issue, at https://github.com/MesserLab/SLiM/issues/90.

I’m not terribly good at qmake, but I have gone over the .pro files with a fine-toothed comb and can’t find anything wrong.  I also actually constructed the whole project again from scratch in Qt Creator, to see whether I had screwed up some modification I had previously done to the .pro files, but the newly created .pro files for the reconstructed project seemed to be identical in all relevant respects to the existing .pro files.

The subdirs-style project contains several subprojects:

QtSLiM: the Qt Widgets app
gsl: a statically linked C library (an edited version of the GNU GSL library)
eidos_zlib: a statically linked C library (an edited version of the standard zlib library)
eidos: a statically linked C++ library
core: a statically linked C++ library
treeseq/tskit: a statically linked C library

Even though QtSLiM links against all of these internal libraries, the link errors due to undefined symbols are only for the gsl and eidos_zlib libraries; everything else seems to link fine.  This seems to point at a problem that is specific to how they are configured/used in the project, of course; but if I compared how they are configured/used to how the other three statically linked libraries are configured/used, I can’t see any difference.

This is probably trivial; it just needs the eyes of someone more competent than myself.  Anyone?  Thanks in advance!

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University



More information about the Interest mailing list