我在編譯時,遇到此錯誤:relocation R_X86_64_32 against `.rodata' can not be used when making a shared object
google 了一下,大部份都是說要加上 -fpic,但我看過 suffixes-rule 的確是已經加上去了。
跟 pre23 對照了一下,pre24 多了 chewing-conf.o 的處理
我試著在 .cpp.o 這規則上也加上 -fpic ,之後就可以編譯通過了。請問這樣是對的嗎?
完整錯誤供參考,如下:
gcc -x c -DUNIX=1 -g -pthread -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pixman-1 -I./IMdkit/include -I./im-client -DDEBUG="0" -DGCIN_TABLE_DIR=\"/usr/share/gcin/table\" -DGCIN_OGG_DIR=\"/usr/share/gcin/ogg\" -DDOC_DIR=\"/usr/share/doc/gcin-1.6.4.pre24\" -DGCIN_ICON_DIR=\"/usr/share/icons/gcin\" -DGCIN_SCRIPT_DIR=\"/usr/share/gcin/script\" -DGCIN_BIN_DIR=\"/usr/bin\" -DSYS_ICON_DIR=\"/usr/share/icons\" -DFREEBSD=0 -DMAC_OS=0 -DG_DISABLE_SINGLE_INCLUDES -DG_DISABLE_DEPRECATED -DGDK_DISABLE_SINGLE_INCLUDES -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_DEPRECATED -I.. -I../IMdkit/include -DCHEWING_DATADIR=\"/usr/share/libchewing3/chewing\" -c chewing-conf.cpp
gcc -x c -DUNIX=1 -g -pthread -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pixman-1 -I./IMdkit/include -I./im-client -DDEBUG="0" -DGCIN_TABLE_DIR=\"/usr/share/gcin/table\" -DGCIN_OGG_DIR=\"/usr/share/gcin/ogg\" -DDOC_DIR=\"/usr/share/doc/gcin-1.6.4.pre24\" -DGCIN_ICON_DIR=\"/usr/share/icons/gcin\" -DGCIN_SCRIPT_DIR=\"/usr/share/gcin/script\" -DGCIN_BIN_DIR=\"/usr/bin\" -DSYS_ICON_DIR=\"/usr/share/icons\" -DFREEBSD=0 -DMAC_OS=0 -DG_DISABLE_SINGLE_INCLUDES -DG_DISABLE_DEPRECATED -DGDK_DISABLE_SINGLE_INCLUDES -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_DEPRECATED -I.. -I../IMdkit/include -DCHEWING_DATADIR=\"/usr/share/libchewing3/chewing\" -c -fPIC -o chewing.pico chewing.cpp
gcc -x c -DUNIX=1 -g -pthread -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pixman-1 -I./IMdkit/include -I./im-client -DDEBUG="0" -DGCIN_TABLE_DIR=\"/usr/share/gcin/table\" -DGCIN_OGG_DIR=\"/usr/share/gcin/ogg\" -DDOC_DIR=\"/usr/share/doc/gcin-1.6.4.pre24\" -DGCIN_ICON_DIR=\"/usr/share/icons/gcin\" -DGCIN_SCRIPT_DIR=\"/usr/share/gcin/script\" -DGCIN_BIN_DIR=\"/usr/bin\" -DSYS_ICON_DIR=\"/usr/share/icons\" -DFREEBSD=0 -DMAC_OS=0 -DG_DISABLE_SINGLE_INCLUDES -DG_DISABLE_DEPRECATED -DGDK_DISABLE_SINGLE_INCLUDES -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_DEPRECATED -I.. -I../IMdkit/include -DCHEWING_DATADIR=\"/usr/share/libchewing3/chewing\" -c -fPIC -o gcin-setup-chewing.pico gcin-setup-chewing.cpp
gcc -shared -fPIC -o chewing-module.so chewing-conf.o chewing.pico gcin-setup-chewing.pico -pthread -L/usr/lib/x86_64-linux-gnu -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lm -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lX11 -ldl -lm -I/usr/include/chewing -lchewing
/usr/bin/ld: chewing-conf.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
chewing-conf.o: could not read symbols: Bad value
collect2: ld returned 1 exit status