我在Linux上構建了一個共享庫(.so),並且我正在編譯和鏈接某個對象,該對象不是在某些函數中動態鏈接的。這些功能是「外部'C''功能。它們出現在共享對象的普通符號表中,但不出現在外部函數列表或動態函數列表中。我正在編譯和使用g ++進行鏈接。我已經關閉了編譯器優化。是否需要設置特殊標誌才能使功能出現?共享庫不能在函數中鏈接
編輯: 我用的對象文件鏈接在一起的命令是這樣的:
g++ -m64 -rpath,/usr/local/Trolltech/Qt-4.8.2/lib -shared -Wl,-soname,libQtCommercialChart.so.1 -o libQtCommercialChart.so.1.0.0 ../build/release/lib/chartdataset.o ../build/release/lib/chartpresenter.o ../build/release/lib/charttheme.o ../build/release/lib/domain.o ../build/release/lib/qchart.o ../build/release/lib/qchartview.o ../build/release/lib/qabstractseries.o ../build/release/lib/chartbackground.o ../build/release/lib/chartelement.o ../build/release/lib/scroller.o ../build/release/lib/chartlayout.o ../build/release/lib/versiontracker.o ../build/release/lib/axisanimation.o ../build/release/lib/xyanimation.o ../build/release/lib/pieanimation.o ../build/release/lib/piesliceanimation.o ../build/release/lib/splineanimation.o ../build/release/lib/baranimation.o ../build/release/lib/stackedbaranimation.o ../build/release/lib/percentbaranimation.o ../build/release/lib/abstractbaranimation.o ../build/release/lib/horizontalbaranimation.o ../build/release/lib/horizontalstackedbaranimation.o ../build/release/lib/horizontalpercentbaranimation.o ../build/release/lib/areachartitem.o ../build/release/lib/qareaseries.o ../build/release/lib/chartaxis.o ../build/release/lib/qabstractaxis.o ../build/release/lib/chartvalueaxisx.o ../build/release/lib/chartvalueaxisy.o ../build/release/lib/qvalueaxis.o ../build/release/lib/chartbarcategoryaxisx.o ../build/release/lib/chartbarcategoryaxisy.o ../build/release/lib/qbarcategoryaxis.o ../build/release/lib/chartcategoryaxisx.o ../build/release/lib/chartcategoryaxisy.o ../build/release/lib/qcategoryaxis.o ../build/release/lib/chartdatetimeaxisx.o ../build/release/lib/chartdatetimeaxisy.o ../build/release/lib/qdatetimeaxis.o ../build/release/lib/bar.o ../build/release/lib/abstractbarchartitem.o ../build/release/lib/qabstractbarseries.o ../build/release/lib/qbarset.o ../build/release/lib/qbarmodelmapper.o ../build/release/lib/qvbarmodelmapper.o ../build/release/lib/qhbarmodelmapper.o ../build/release/lib/qbarseries.o ../build/release/lib/barchartitem.o ../build/release/lib/qstackedbarseries.o ../build/release/lib/stackedbarchartitem.o ../build/release/lib/qpercentbarseries.o ../build/release/lib/percentbarchartitem.o ../build/release/lib/qhorizontalbarseries.o ../build/release/lib/horizontalbarchartitem.o ../build/release/lib/qhorizontalstackedbarseries.o ../build/release/lib/horizontalstackedbarchartitem.o ../build/release/lib/qhorizontalpercentbarseries.o ../build/release/lib/horizontalpercentbarchartitem.o ../build/release/lib/qlegend.o ../build/release/lib/legendmarker.o ../build/release/lib/legendlayout.o ../build/release/lib/linechartitem.o ../build/release/lib/qlineseries.o ../build/release/lib/qpieseries.o ../build/release/lib/piesliceitem.o ../build/release/lib/piechartitem.o ../build/release/lib/qpieslice.o ../build/release/lib/qpiemodelmapper.o ../build/release/lib/qvpiemodelmapper.o ../build/release/lib/qhpiemodelmapper.o ../build/release/lib/qscatterseries.o ../build/release/lib/scatterchartitem.o ../build/release/lib/qsplineseries.o ../build/release/lib/splinechartitem.o ../build/release/lib/xychart.o ../build/release/lib/qxyseries.o ../build/release/lib/qxymodelmapper.o ../build/release/lib/qvxymodelmapper.o ../build/release/lib/qhxymodelmapper.o -L/usr/local/Trolltech/Qt-4.8.2/lib -L/tmp/qcharts/lib/release -Wl,-rpath,/tmp/qcharts/lib/release -lQtGui -L/usr/local/Trolltech/Qt-4.8.2/lib -L/usr/X11R6/lib64 -lQtCore -lpthread
,並用於建立與丟失的功能對象的命令是這樣的:
g++ -c -m64 -pipe -fvisibility=hidden -fvisibility-inlines-hidden -O0 -Wall -W -D_REENTRANT -fPIC -DQTCOMMERCIALCHART_LIBRARY -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.8.2/mkspecs/linux-g++-64 -I. -I/usr/local/Trolltech/Qt-4.8.2/include/QtCore -I/usr/local/Trolltech/Qt-4.8.2/include/QtGui -I/usr/local/Trolltech/Qt-4.8.2/include -I../include -I../include -I. -Ianimations -Iareachart -Iaxis -Iaxis/valueaxis -Iaxis/barcategoryaxis -Iaxis/categoryaxis -Iaxis/datetimeaxis -Ibarchart -Ibarchart/vertical/bar -Ibarchart/vertical/stacked -Ibarchart/vertical/percent -Ibarchart/horizontal/bar -Ibarchart/horizontal/stacked -Ibarchart/horizontal/percent -Ilegend -Ilinechart -Ipiechart -Iscatterchart -Isplinechart -Ithemes -Ixychart -I../build/release/lib -o ../build/release/lib/versiontracker.o versiontracker.cpp
讓我們看看你的'g ++'命令和你得到的錯誤。 – Foggzie
http://stackoverflow.com/q/3588476/1741542是一個關於使用gcc構建共享庫的綜合性問題。 –
@Olaf:那不是「全面的」 - 這是一個破碎的混亂! –