尽管符号链接已存在

时间:2017-10-16 08:51:52

标签: c++ linux linker shared-libraries ld

我正在尝试编译需要SFML 2.41+的程序。 Ubuntu 16.04的repos没有足够新版本,所以我按照this page上的(有点稀疏)指令安装了SFML 2.4.2。具体来说,我从this page下载了Linux版本,将其解压缩,然后向下挖,直到找到libshareinclude文件夹并将这些文件夹复制到文件夹中。同名/usr/local/

运行包含的Makefile时,我收到以下错误:

/usr/bin/ld: cannot find -lsfml-system
/usr/bin/ld: cannot find -lsfml-window
/usr/bin/ld: cannot find -lsfml-graphics

暂时关注sfml-system,如果我运行ld -lsfml-system --verbose | grep /usr/local/lib,我会得到以下内容:

attempt to open //usr/local/lib/x86_64-linux-gnu/libsfml-system.so failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libsfml-system.a failed
attempt to open //usr/local/lib/libsfml-system.so failed
attempt to open //usr/local/lib/libsfml-system.a failed

如果我运行sudo ls -l /usr/local/lib | grep libsfml-system.so,我会收到以下信息:

lrwxrwxrwx  1 root   root        21 Oct 16 01:38 libsfml-system.so -> libsfml-system.so.2.4
lrwxrwxrwx  1 root   root        23 Oct 16 01:38 libsfml-system.so.2.4 -> libsfml-system.so.2.4.2
-rw-r--r--  1 root   root     72080 Feb 10  2017 libsfml-system.so.2.4.2

所以我似乎在.so路径中的ld文件中有一个符号链接。 为什么不能加载库?

(我最初担心的是双斜线,但this question表明这些都没关系。)


到目前为止我尝试了什么

我现在尝试运行sudo ldconfigsudo ldconfig /usr/local/lib/。这些都没有改变ld -lsfml-system

的行为

具体来说,当我运行sudo ldconfig --verbose 2> /dev/null | grep sfml时,我得到了

    libsfml-window.so.2.4 -> libsfml-window.so.2.4.2
    libsfml-graphics.so.2.4 -> libsfml-graphics.so.2.4.2
    libsfml-audio-d.so.2.4 -> libsfml-audio-d.so.2.4.2
    libsfml-graphics-d.so.2.4 -> libsfml-graphics-d.so.2.4.2
    libsfml-audio.so.2.4 -> libsfml-audio.so.2.4.2
    libsfml-window-d.so.2.4 -> libsfml-window-d.so.2.4.2
    libsfml-system.so.2.4 -> libsfml-system.so.2.4.2
    libsfml-system-d.so.2.4 -> libsfml-system-d.so.2.4.2
    libsfml-network-d.so.2.4 -> libsfml-network-d.so.2.4.2
    libsfml-network.so.2.4 -> libsfml-network.so.2.4.2
    libsfml-network.so.2.3 -> libsfml-network.so.2.3.2
    libsfml-graphics.so.2.3 -> libsfml-graphics.so.2.3.2
    libsfml-system.so.2.3 -> libsfml-system.so.2.3.2
    libsfml-window.so.2.3 -> libsfml-window.so.2.3.2

(在stderr上我只收到看似仅供参考的消息,例如:

/sbin/ldconfig.real: Path `/usr/local/lib' given more than once

/sbin/ldconfig.real: /lib/i386-linux-gnu/ld-2.23.so is the dynamic linker, ignoring

所以我认为它们并不重要。)


自提到/etc/ld.so.cache以来,我使用cp /etc/ld.so.cache /etc/ld.so.cache.bak复制了该文件并重新运行sudo ldconfig。生成了一个新的缓存文件但没有任何不同,即diff /etc/ld.so.cache /etc/ld.so.cache.bak不会打印任何内容。

2 个答案:

答案 0 :(得分:2)

问题是,当我将文件复制到/usr/local/lib/上时,SELECT b.booking_id,b.booking_ref,b.destination,b.room_format,b.checkin,b.checkout,b.booking_status,b.currency,b.rooms,b.booking_date, b.adults,b.childs,b.seniors,b.youth,b.child2,b.booking_type, pb.amount_charged,pb.original_total_cost 'total_amount',b.special_request,b.cancelled_date,b.emergency_contact,b.emergency_email, (SELECT TOP 2 CAST(isbreakfast AS VARCHAR(10)) + '_' + room_desc FROM tbl_hotel_room_booking WHERE pb.product_booking_id = product_booking_id) 'room_desc', tba.traveller_address1,tba.traveller_address2,tba.traveller_city, tba.traveller_state,tba.traveller_country,tba.traveller_zip_code, th.transaction_amount,th.reversal_amount,th.branch_id,th.agent_id,th.transaction_type, pb.product_booking_id,pb.product_status,pb.provider_confirmation_code,pb.booking_source,pb.product_name,pb.product_type,pb.product_id, tft.ticket, (SELECT TOP 1 as_of_date + '_' + hotel_penalty FROM tbl_hotel_room_cancellation WHERE booking_id='0BCE1ABC-EA42-4030-A9F1-CA8D176825C0') 'as_of_date', tpd.adult_price,tpd.cost_currency,tpd.sell_currency,tpd.booking_fee,tpd.taxes,tpd.exchange_rate,tpd.subagency_markup_val, tpd.charged_amount,tpd.child_price,tpd.senior_price,tpd.youth_price, tpd.actual_price,(ISNULL(tpd.markup_total,0) + ISNULL(tpd.subagency_markup_val,0)) 'markup_total', tpd.markup_total 'agency_markup' FROM tbl_booking b INNER JOIN tbl_product_booking pb ON b.booking_id = pb.booking_id LEFT JOIN tbl_transaction_history th ON b.booking_ref = th.reference_number LEFT JOIN tbl_traveller_billing_address tba ON b.booking_id = tba.booking_id LEFT JOIN tbl_purchasedproduct_details tpd ON b.booking_id = tpd.booking_id LEFT JOIN tbl_flight_tickets tft ON b.booking_id = tft.booking_id WHERE b.booking_id = '0BCE1ABC-EA42-4030-A9F1-CA8D176825C0' AND (th.transaction_type IS NULL OR LOWER(th.transaction_type) = 'booking' OR LOWER(th.transaction_type) = 'creditcardbooking' OR Lower(th.transaction_type) = 'manualbooking') 上的权限发生了变化。具体来说,执行位似乎未被设置。再次设置后,我现在可以正确链接这些库了!

答案 1 :(得分:0)

标准Linux库缓存在/etc/ld.so.cache中。如果将库添加到标准路径,则还需要运行(以root身份)ldconfig