Re: Linking issue on MacOS Catalina (using XCode)

Samyukta Yagati <[email protected]>
Newsgroups gmane.comp.encryption.cryptopp
Message-ID <[email protected]>
As a follow up: I tried running  

>> clang++ -g2 -O3 -l /usr/local/include /usr/local/lib/libcryptopp.a -WI,-L

And got the error:

ld: library not found for -l/usr/local/include
clang: error: linker command failed with exit code 1 (use -v to see 
invocation)

It seems like the intention of this command was to ask clang to link to the 
include path to crypto++ but clang doesn't have the include path on in its 
build tools? Further suggestions or clarifications would be great, I tried 
googling again and couldn't find anything.
On Thursday, September 16, 2021 at 12:04:00 PM UTC-7 Samyukta Yagati wrote:

> I'm new to using clang, so to clarify: in my case, I should try "clang++ 
> -g2 -O3 -I /usr/local/include cryptopp -Wl,-L" (where cryptopp is a 
> subdirectory of include)? Also, is "-Wl,/usr/local/lib -o test.exe" 
> intended to be shorthand for "clang++ -g2 -O3 -Wl,/usr/local/lib -o 
> test.exe"? (and, relatedly, what output should I expect in test.exe?)
>
>
>
> On Wednesday, September 15, 2021 at 4:58:05 PM UTC-7 Jeffrey Walton wrote:
>
>> On Wed, Sep 15, 2021 at 6:39 PM Samyukta Yagati <[email protected]> 
>> wrote:
>> >
>> > I installed Crypto++ from source as follows:
>> >
>> > git clone https://github.com/weidai11/cryptopp.git
>> > cd cryptopp
>> > Uncommented the CXX flag line in GNUmakefile that adds "-stdlib=libc++" 
>> because I am using XCode.
>> > make -j 8 (8 = value of $(nproc) on my machine if it were linux)
>> > sudo make install
>> >
>> > The make and install complete without errors. I confirmed that 
>> /usr/local/lib contains libcryptopp.a.
>> >
>> > When I try to use libcryptopp in a project (in a different directory 
>> from the cryptopp install), clang (Apple Clang 12.0.0) can't find it. I get 
>> the following error message:
>> >
>> > + LD lib/crypto_bench
>> > ld: library not found for -l:libcryptopp.a
>> > clang: error: linker command failed with exit code 1 (use -v to see 
>> invocation)
>> >
>> > ...
>> >
>> > I also tried updating my PATH variable in bash_profile with the 
>> location of libcryptopp as follows, then source'd bash_profile again:
>> >
>> > export PATH="/usr/local/lib:$PATH"
>> >
>> > However, this resulted in the same error as before when I tried to 
>> compile the project. I've spent several hours googling and haven't been 
>> able to find a fix, and I'm wary of manually symlinking the file because it 
>> can break other installs on my laptop. Any help with fixing this issue 
>> would be much appreciated.
>>
>> When linking, use -L to provide a path to the linker. That is, you
>> invoke ld directly. If you are passing the linker option through the
>> compiler driver, then use -Wl,-L -Wl,<path>
>>
>> So you would probably use something like:
>>
>> clang++ -g2 -O3 -I /usr/local/include test.cxx -Wl,-L
>> -Wl,/usr/local/lib -o test.exe
>>
>> You would have to do the same on, say, CentOS, Fedora and Red Hat. Red
>> Hat does not put /usr/local on-path for the build tools.
>>
>> Jeff
>>
>

-- 
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/7405a8e9-7cad-45a3-b3ab-ac1853c6d227n%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.