Devolutions / conan-rs

A Rust wrapper of the conan C/C++ package manager (conan.io) to simplify usage in build scripts
Apache License 2.0
36 stars 11 forks source link

successfully gotten to compile but project in CXX fails at linker stage #12

Closed EMCP closed 12 months ago

EMCP commented 1 year ago

I just wanted to checkin if I am doing something wrong with my conan package.. I have updated my recipe to call out the system library dependency.. but CXX still cannot find my libraries built.. everything works in C++ just fine so I am a bit lost

https://github.com/dtolnay/cxx/issues/1132#issuecomment-1328020950

note: /usr/bin/ld: /home/emcp/Dev/git/JRGEMCP_Bootstrapping/bootstrap-rust-cpp-conan/target/debug/build/twsapi_grpc_server-f1ae9ab28f1e650b/out/libtwsapi-grpc-server.a(twsapi-client.o): in function
 `decimalToString[abi:cxx11](unsigned long long)':                                                                                                                                                       
          /home/emcp/.conan/data/twsapi/10.20.01/stonks/prod/package/062863c92a5a0a247840166e9f84ebe8d10786b9/include/Decimal.h:68: undefined reference to `__bid64_to_string'    

the conanmanifest.txt

1669456927
bin/JavaDDE.dll: 8a1c959be15a0b8701dbe83338a8f9fa
bin/JavaDDEx64.dll: 4153f04a310ca3610771fc8e35e3c8bc
bin/biddll.dll: 5b6664fa454d750709cfe4b6aff762de
conaninfo.txt: 33600f202dc2ac2783c2a606f6678d2a
include/CommissionReport.h: dc3e59f802e48f98a5d442b3f828fda1
include/CommonDefs.h: 76c431e6b6cf28f85431cf7922b42b62
include/Contract.h: 30f22cc07544fd2927c6d55a0aa8f532
include/ContractCondition.h: 338c06207c139eb50727a405b45711f2
include/Decimal.h: b0ae33c9bd1ba429cdc8b64e837f50de
include/DefaultEWrapper.h: 9ef79c5f2bf05f84f2f6cd71ecf011a9
include/DepthMktDataDescription.h: d152ac5211dfeb932bc0d09a5c68efcc
include/EClient.h: e0b8c74d4799ab1f69b369d455e7d401
include/EClientException.h: 364391057b8d129c5fd3048d04cbd25b
include/EClientMsgSink.h: 039f0d72c18cdfd56f2cc086a192a51c
include/EClientSocket.h: 102edd49f5990a996c6d0a313ecde069
include/EDecoder.h: 230fbc655a959aa710dd81c8a3f02006
include/EMessage.h: 1864a7e06e49bd0900aeb2d540d092d9
include/EMutex.h: 13c65b792e117577f6aa0336080063c0
include/EOrderDecoder.h: 33fb1a5d8c80a1be4f8014b621c9a9dc
include/EPosixClientSocketPlatform.h: 2b4f8e35b523b8c315f8dc10d95f5690
include/EReader.h: bfd2cb150eb1b5ec7d4d0902c50a446f
include/EReaderOSSignal.h: 2646cf85790a77d02393f9601d2bbe6b
include/EReaderSignal.h: 3445b62e82330d96c1d0960c024323fc
include/ESocket.h: 3bf392a921426990e88345f099a0f741
include/ETransport.h: b22da11d30137acaf4cccbbb472cf40c
include/EWrapper.h: 85862b206fc8b39d3b6b025333b24dc6
include/EWrapper_prototypes.h: 72055e8bb6cb53387369e502d3f82937
include/Execution.h: 478a674269396ca20591b92fe21b354f
include/FamilyCode.h: 046882fb077fbff4d78b1dbf995817d4
include/HistogramEntry.h: af34b4f4150a52d02ac4fb55f5b4c154
include/HistoricalSession.h: d72aa4d4789c878d50e1dca8720af7e8
include/HistoricalTick.h: c2ce30d543a14a7f11e2346c2850ec3e
include/HistoricalTickBidAsk.h: 8d8f66466bd6c7df8efa0934ec03fdcc
include/HistoricalTickLast.h: 496d5cf9a17da5c0fbf801e1b8b2a95c
include/IExternalizable.h: 1a2e529c48ba52df4e32419233bdf5a8
include/MarginCondition.h: c61677888e52bed6b50f7d1d45a19754
include/NewsProvider.h: a9f74105139aee84ac5d8afe1a394703
include/OperatorCondition.h: 40f8f0b64dca4e51b363ab6a47de4d81
include/Order.h: 6cbb997c8f5d6769e3000ffdfdfc29b2
include/OrderCondition.h: 08ac57efc6741c2a4f1bc3fe0f2776d9
include/OrderState.h: 7f41dd41f907e004c32976e32b748b95
include/PercentChangeCondition.h: bf5390b73ae673332aedd894923df088
include/PriceCondition.h: 08e42b5739a570fe841f110c8919d93f
include/PriceIncrement.h: 314f7ff3ebfec3f6badd9e44d9373fc8
include/ScannerSubscription.h: ab96323b2f493905ed21390363210d8c
include/SoftDollarTier.h: 448e6a16b69815de1e3e61247e6497fc
include/StdAfx.h: 4c2a04d94745ac8b28cfed549b4254cc
include/TagValue.h: 4b78a41afdad69f0d2fc9915b6d0c8a1
include/TickAttrib.h: 9544d8b0c33549eda8390da1ac196c7e
include/TickAttribBidAsk.h: 1fb4dd1e86e4ff6f4c9827d6954dd96f
include/TickAttribLast.h: 8ace281e3f228bbfe9364755276d193e
include/TimeCondition.h: 4d9557059924f1c7b4cbbbe4d354099f
include/TwsSocketClientErrors.h: fb95ef037bf3f60c86cc0af52e9b05a7
include/VolumeCondition.h: 4190af00ee3e0db634fa42da3a292dbc
include/WshEventData.h: 4688ce2c6c52e3d01fd08b622fdb0650
include/bar.h: ffd367caa980641090a092d7f75e7b2e
include/executioncondition.h: efd9496785ff162315abe48095cd24c7
include/platformspecific.h: afb49774959ec5d8fd045b60f1fba9f2
include/resource.h: f94777f52839d6193582e03ae215fd01
lib/biddll.lib: 35d3c5d1935a045e632f9537a1bf35be
lib/libbid.a: cc99fe8df80f9a360674c91b5023aae0
lib/libbid.lib: 1fa5d341302f79a3a7eb502b27c631c3
lib/libbid.so: e4bd934330ddeb5ba21cf1e08d7cbf19
lib/libtwsapi.a: 3c060cc878f1115e8fe49ef5a02afd1b

I added the system library dep like so

def package_info(self):
    self.cpp_info.libs = ["twsapi"]
    self.cpp_info.system_libs = ["bidgcc000"]

https://stackoverflow.com/a/74475762/389976

but seems CXX just cannot find what C++ 's GCC normally can via regular conan

Any thoughts? if it's clearly not a conanRS issue feel free to close, thanks for looking

tom-anders commented 1 year ago

For me, the solution was the following:

1) Make sure your building static instead of shared libs

# in conanfile.txt
[options]
your_lib:shared=False

2) cargo_emit() will result in cargo:rustc-link-lib=your_lib, which does not take into account that you built a static lib (this looks like a bug to me)

To fix this, you need to manually print the correct line:

// in build.rs
println!("cargo:rustc-link-lib=static=your_lib");
EMCP commented 12 months ago

thank you @tom-anders for the static option tip.. I have added that.. I have paired back the project to just see if I can get it to build with a hello world CXX now.. full post is in discourse https://users.rust-lang.org/t/cxx-noob-with-simple-hello-world-not-finding-my-library-function/100957

I think I can close this ticket until that more basic issue is resolved now.. but I think your tip has helped