Re: Linking issue on MacOS Catalina (using XCode)

Samyukta Yagati <[email protected]>
Newsgroups gmane.comp.encryption.cryptopp
Message-ID <[email protected]>
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/9d368cb4-7206-458f-9bd7-3a4796ac9df9n%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.