Mingw and Eclipse unable to find library - 2 - c

I am faced with the exact same situation as the question raised by Gustavo in the following Link. Also, I have tried all the solutions posted in that link and other tags (such as changing library names from opus.a to libopus.a, change '\' to '/' and so on) but none of these have solved my problem. By opening the properties of the library file, these are the following things displayed:
Path: /demo/opusfile/libopusfile.a
Type: File (Static Library)
Location: U:\data\Jag\eclipse\wrksp\demo\opusfile\libopusfile.a
The error message displayed by Mingw is as follows:
15:56:57 **** Incremental Build of configuration Debug for project demo ****
Info: Internal Builder is used for build
gcc -o demo.exe "src\\demo.o" -lU:/data/Jag/eclipse/wrksp/demo/opusfile/libopusfile.a
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lU:/data/Jag/eclipse/wrksp/demo/opusfile/libopusfile.a
collect2.exe: error: ld returned 1 exit status
collect2.exe: error: ld returned 1 exit status
Could someone please let me know what am I missing ? I am not able to resolve this issue

I think I found the solution, thanks to the answer posted in this Link. So basically to summarize the solution, I had to remove the 'lib' prefix, the '.a' suffix and the library path when I specified the libraries (-l parameters). The library path has to be specified in the -L parameter . This resolved the above problem but led to another hurdle by Mingw:
libopusfile.dll.a: could not read symbols: Archive has no index; run ranlib to add one.
I executed the 'ranlib' command in the command prompt
cmd_path> ranlib libopusfile.dll.a
, as suggested by the compiler, and this solved all my issues!

Related

gprbuild fails to include a file needed for gnatcoll

I tried to build something with GnatColl from GPS Community 2021 on Fedora 35. The linker failed, saying
ld: /path/to/common/Ada/Quoter/obj/gnatcoll-refcount.o: in function `gnatcoll__refcount__sync_bool_compare_and_swap':
gnatcoll-refcount.adb:(.text+0x622): undefined reference to `gnatcoll_sync_bool_compare_and_swap_access'
collect2: error: ld returned 1 exit status
This also fails if I try to run the project using gprbuild -P Quoter.gpr.
I can fix this from the command line by copying the failed command (gcc ...) and adding ~/opt/GNAT/2021/include/gnatcoll/gnatcoll_support.c to the list of files to compile, as that's the included file with the desired function. That's awfully inconvenient, though.
I guess I have something configured slightly wrong. Might anyone here have an idea?
I found the answer, and it's a bit embarrassing, but looking in the gnatcoll examples would have done it: add with "gnatcoll"; to the beginning of the gpr file.

Cannot Find Libraries [error: ld returned 1 exit status]

As the title suggests, I am having a problem linking some libraries to my code. Minuit2 is in
/home/christian/root/include
and when I compile I run the following:
g++ -I/home/christian/root/include niminimzationExample.cpp -o niminimzationExample -L/Minuit2/lib -lMinuit2
which gives me the following error
/usr/bin/ld: cannot find -lMinuit2
collect2: error: ld returned 1 exit status
Being a newbie, I am not even sure what the error exactly means or how to fix it. I run Minuit2 on another machine, which the same command, and everything works fine. Any help would be greatly appreciated.
Thanks,
Christian
I am not even sure what the error exactly means
The error means: linker searched for a file named libMinuit2.so and libMinuit2.a in /Minuit2/lib/ and then standard directories (usually /usr/lib and /lib), and didn't find it anywhere.
or how to fix it.
You need to find the directory in which one or both of libMinuit2.{so,a} are located, and then use -L/that/directory at link time to tell the linker where to find the library.

fatal error: sodium.h: No such file or directory

Thank you #stark I was unaware you had to link the directory as part of #include. This part is now working though when I include.
(sodium_init() < 0)
{
printf("Sodium could not be initialized");
return 1;
}
I now receive the error "undefined reference to 'sodium_init'.
I have tried adding -lsodium to the compile command (gcc -g -lsodium file1.c file2.c file1.h -o file1.c.exe) which gives the error.
"cannot find -lsodium collect2.exe: error: ld returned 1 exit status"
Through further searching I believe I need to tell the compiler where to find -lsodium though cannot find out how.
-- below has been solved using #stark advice --
I have been trying to get the sodium library working for the last 3 days. I have followed the instillation instructions here(https://libsodium.gitbook.io/doc/installation) which all appear to have completed successfully, but still receive the error.
I then found information suggesting I have not linked Visual Studio (community edition) to the library location.
I have attempted to follow the instructions here(https://www.learncpp.com/cpp-tutorial/a2-using-libraries-with-visual-studio-2005-express/) but cannot see "VC++ Directories". I have tried several other sets of directions with the same outcome.
Is anyone able to help getting the sodium library working so I can get access to the RtlGenRandom() function?

iotovity croos compilation fails.

Greetings
I am new to iotivity and following the iotivity wiki guidelines for understanding and building framework.(on Ubuntu 16.04)
AIM - For ARM Cross Compilation. We are following the below Iotivity link.
https://wiki.iotivity.org/iotivity_porting_to_arm_based_platforms?s[]=arm&s[]=based&s[]=platforms
Described below Step 4 as mention in the link .
We are using arm-linux-gnueabi compiler which support build for our tager Artik 520 - ARM Cortex A7 processer.
4) Download the UUID Header/Libraries for arm architecture from Internet or from linkuuid-arm.zip. Place the UUID Headers/Libraries inside IoTivity folder (For Eg: iotivity/extlibs/). Update the CPPPATH/LIBPATH for UUID Headers/Libraries in required SConscript
As describe above i have followed the steps.
-Issue is the uuid-arm folder doesn't have any defulat SConscript when unzip(only header and lib folder) and it is not Cleary mention which is the required SConscript to add below lines. The uuid.so is present in the uuid-arm lib folder.below are the lines which are mention need to be added.i am confused on this which will be the required Sconscripts and how to debug this. Kindly help on this.
For E.g.: env.AppendUnique(CPPPATH = [ '<uuid header path>'])
env.AppendUnique(LIBPATH = ['<uuid Library Path>'])
env.AppendUnique(LIBS = ['uuid'])
{{:arm_uuid_path.png?200|}} -----> This line itself is a syntax error to add anywhere.
Build Command
scons TARGET_OS=linux TARGET_ARCH=arm TARGET_TRANSPORT=IP SECURED=0 RELEASE=1 TC_PREFIX=arm-linux-gnueabi- TC_PATH=/usr/arm-linux-gnueabi/bin
ERROR
scons: Building targets ...
scons: building associated VariantDir targets: out/linux/arm/release Linking out/linux/arm/release/resource/csdk/connectivity/src/libconnectivity_abstraction.so
/usr/lib/gcc-cross/arm-linux-gnueabi/5/../../../../arm-linux-gnueabi/bin/ld: cannot find -luuid
collect2: error: ld returned 1 exit status
scons: *** [out/linux/arm/release/resource/csdk/connectivity/src/libconnectivity_abstraction.so] Error 1
scons: building terminated because of errors
Thanks for help..
From the error message, it looks like the path to the uuid library is not updated properly in the scons file.
Can you please share your changes in the scons file, specifically the below lines.
env.AppendUnique(CPPPATH = [ '<uuid header path>'])
env.AppendUnique(LIBPATH = ['<uuid Library Path>'])
env.AppendUnique(LIBS = ['uuid'])
I hope you have updated the ['< uuid Library path>'] with your absolute path, which may be /root/workspace/iotivity/extlibs/uuid
Agreed, {{:arm_uuid_path.png?200|}} is not a proper scons syntax. It looks like a webpage error to me, instead of the image file, just the path is included

arm toolchain does not seem to have C libraries

I am trying to cross compile a simple program with the arm toolchain. And stdio library points to another library, which results in the following error:
/home/sansari/tools/arm-eabi-4.7/bin/arm-eabi-gcc hello.c -o hello
In file included from hello.c:3:0:
/home/sansari/tools/arm-eabi-4.7/bin/../lib/gcc/arm-eabi/4.7/include-fixed/stdio.h:50:23: fatal error: sys/cdefs.h: No such file or directory
compilation terminated.
make: *** [hello] Error 1
At first, I thought this file is in some subdirectory of the toolchain, and I need to include the folder for this library in my makefile. But a quick tree output says that it is not. So given that I have used this toolchain successfully for a larger project, I know it is copied from somewhere. So my question is how do I add it to this project please? And what is the appropriate place to copy it from? I am trying to understand why it is not in the toolchain folders that I have, and how I should add it to my project please.
#Olaf - You have been very helpful; I however have a little more learning curve. But I do understand what you are instructing. I know I have the libraries in my build system since have built for this platform successfully. I even know that it is in my WORKING_DIRECTORY. What I do not know is if I can copy a folder and address the issue entirely or do I need to keep compiling and see what errors I get. That is do it incrementally. For example, one of the files, which was missing was cdefs.h. And I was able to find it in the folder:
/home/sansari/ndk/android-ndk-r10d/platforms/android-19/arch-arm/usr/include/sys/cdefs_elf.h
So I copied it over and the build process proceeded to the next stage. I do like to know if I should perhaps have copied the entire /sys or /include directory or compared the /include directory of my source and make sure all the files are also in the destination directory also. And that way I can avoid having to compile a number of times.
But nevertheless, I proceeded with copying one file at a time. The last error I got is:
/home/sansari/tbt/tools/arm-eabi-4.7/bin/../lib/gcc/arm-eabi/4.7/include/stdint.h:3:26: fatal error: stdint.h: No such file or directory
And I look in the include directory; I see a file call stdint.h
What do you make of that? Does that make sense to you? I am confused by this error. How can I get this error when the file is in the directory. Basically it seems make is saying this file does not exist when it does.
I did find This post also, which seems to say what you are saying. I just need to know what is the best way to address it.
#Olaf - I really appreciate all your help. I was able to get through all the library errors by putting an include statement in my makefile. Now the linker is giving me errors as follows:
/home/sansari/tbt/tools/arm-eabi-4.7/bin/arm-eabi-gcc -I../../ndk/android-ndk-r10d/platforms/android-19/arch-arm/usr/include hello.c -o hello
/home/sansari/tbt/tools/arm-eabi-4.7/bin/../lib/gcc/arm-eabi/4.7/../../../../arm-eabi/bin/ld: cannot find crt0.o: No such file or directory
/home/sansari/tbt/tools/arm-eabi-4.7/bin/../lib/gcc/arm-eabi/4.7/../../../../arm-eabi/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
make: *** [hello] Error 1
update - I searched for a solution for the above errors. The first error is discussed here and -nostartfiles switch seems to work for me for now. I found this link that talks about libc.a being the fix for the error about not finding -lc. So I found an appropriate copy of libc.a and passed the location to the linker. The program compiles, but I get one last warning as follows:
warning: cannot find entry symbol _start; defaulting to 00000000000080dc
For which this link suggested using --entery-main switch. So now I have an executable. I want to thank you again. If you do see any problem in what I have done, please post something for me. it is gonna take a while for me to get this executable on my device.

Resources