Add BASS library in Code::Blocks on Linux - c++

Can somebody help me with adding BASS library in Code::Blocks on Ubuntu? But step by step. I tried many things and I can't do this... I have "bass24-linux.zip" file and what now? Please help me as soon as possible!
EDIT:
I will tell you what Im doing:
Unzipping "bass24-linux.zip" on Desktop.
Copying "bass.h" to /usr/include
Copying "libbass.so" to /usr/lib
In Code Blocks going to Settings->Compiler->Search directories
Setting compiler path to /usr/include (where bass.h is)
Setting linker path to /usr/lib (where libbass.so is)
Then going to the project build options->Linker settings and set path ../../../../../usr/lib/libbass.so;
Then I'm writing a simple program, for example:
#include <iostream>
int main(){
}
And then I see error:
g++ -L/usr/lib -o bin/Debug/LightBulb obj/Debug/main.o ../../../../../usr/lib/libbass.so ../../../../../usr/lib/libbass.so: error adding symbols: File in wrong format collect2: error: ld returned 1 exit status

Related

OSX: clang / ld says it can't find a static library even though it exists and all parameters are correct

I know it's going to be a silly mistake, and I'm aware that there are similar posts however none have helped so far, so I'm resorting to a new post.
I'm trying to compile the simplest GLFW hello world example.
In my project directory (I'm using vscode) there is a main.cpp file, and the glfw lib file I downloaded from glfw.org which I renamed to libglfw3.a (It's precompiled) I am using a MacBook Air M1.
I'm trying to compile it with this command:
clang -I /opt/homebrew/Cellar/glfw/3.3.7/include -L /Users//projects/ -l libglfw3.a main.cpp -o helloglfw
The output I get is:
ld: library not found for -llibglfw3.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm clearly dumb because for the life of me I can't see what I'm doing wrong...
Things I've tried:
linking to the homebrew version of glfw which contains a .dylib of glfw
tried linking libglfw3 (without the .a extension)
compiling to an object file and then linking with ld separately
using g++
Not using the -L flag and just pasting the full path into -l
Praying and restarting the pc just in case.
Waiting for it to fix itself
Some assistance would be appreciated.
OK SO! I fixed it. Apparently it works if there is NO SPACE between the -L and -l parameters.
so the command looks like this:
clang <source files> -I<Include Paths> -L<pathtolibs>-l<libs>
No clue why, but whatever I'm done...

SDL2 error messages won't go away

Compile command/what's in the .bat:
g++ -o program.exe SME.cpp -w -Wl -subsystem,windows -lmingw32 -lSDL2main -lSDL2
pause >nul
SME.cpp:
#include "SDL2\SDL.h"
int main()
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Quit();
return 0;
}
I have build.bat, SME.cpp and SDL2.dll in a folder
MinGW is in the default C:\MinGW directory
I installed MinGW using the installer
I added C:\MinGW\include
I put the SDL2 header files in C:\MinGW\include\SDL2\
I put the SDL2 library files (SDL2main.lib and SDL2.lib) in C:\MinGW\lib.
I added C:\MinGW\bin to the Path variable
I've solved all of the previous problems by looking on the internet for answers to them
The compiler keeps complaining that there is an undefined reference to SDL_Init and SDL_Quit and that ld.exe (I have no idea what that is) has returned exit status 1 due to an undefined reference to #WinMain16.
I've searched everywhere and there is a short supply of answers to this problem and all of the answers I've come across haven't worked. I've tried 3 different ways of doing this: with a .bat, with a Makefile and with Eclipse. It always comes down to these three errors. I have no idea what is going wrong, I checked and SDL_init.h and SDL_quit.h both exist. I don't know what #WinMain16 is either.

Linking to ROOT files in xCode

I need to link to the .so files and headers found in /root/lib and /root/include in a project in xcode 3.2.6. ROOT is an analysis framework from CERN.
There is a utility root-config, that will return all the libraries necessary, I can compile on the command line using:
CFLAGS = `root-config --cflags`
GLIBS = `root-config --glibs`
test : main.cpp main.h
g++ $(CFLAGS) $(GLIBS) -g -Wall main.cpp -02 -o test
Program runs fine with no bugs. But, I want to use xcode for the whole project, but can't get it to either
A: use this utility
or
B: search the right paths to the .so files. I have included /root/lib and /root/include in the build variables header_search_paths and library_search_paths under the build settings. I then actually type in the files I need into the other_linker_flags like so:
-llibTree -llibHist -llibRIO -llibCint -llibCore
xcode returns the message:
ld: library not found for -llibTree
collect2: ld returned 1 exit status
Command /Developer/usr/bin/g++-4.2 failed with exit code 1
Does anybody know whats going on? Can xCode compile .so files? Is there some other issue here?
This has nothing to do with ROOT. To link against a library named libSomething.so in your library search path you can use a linker flag -lSomething. You want to link against e.g. libTree.so, so the correct flag to use would be -lTree, not -llibTree which would look for liblibTree.

Adding Boost Library to a C++ project in OS X Eclipse

I am have been attempting to get a C++ project setup using boost file system library using eclipse. I followed these directions to install boost on my system. The directions where pretty much
download
extract
run bootstrap.sh
run ./bjam architecture=combined
That seemed to go fine, no errors. I then fired up eclipse and created a new test project called test with a single file called test.cpp. The code in it is:
#include <stdio.h>
#include <boost/filesystem.hpp>
int main() {
boost::filesystem::path path("/Users/schoen"); // random pathname
bool result = boost::filesystem::is_directory(path);
printf("Path is a directory : %d\n", result);
return 0;
}
This is just something simple to make sure it is all set up correctly. Of course I tried to compile at this point and it failed. Did some googling and found this site. It said to add the boost library to the linker by going to project properties and adding "boost_filesystem". I tried this, and well it didn't work.
Can someone point me in the right direction or give me a hint to how to set up Boost in an Eclipse project?
I am new to C++ and Eclipse, and most my experience is in Java with Netbeans. So I am pretty lost at the moment.
UPDATE
I just wanted to update on what I have tried based on the answers given.
Based on Alex's suggestion I added boost_system and boost_filesystem to the linker list. I was still getting the same compiler errors.
Following the suggestion from rve I added the path to the boost libraries to the Library search path. When this did not work. I cleared out the linker list and tried it with just the library search path. This also did not work.
I then cleared the Library search path. I then manually edited the command on the linker window to be 'g++ -L/Users/jacobschoen/Library/boost_1_45_0/stage/lib -lboost -lboost_filesystem'. This also did not work.
In all of these I tried setting the path to boost to be '/Users/jacobschoen/Library/boost_1_45_0' and '/Users/jacobschoen/Library/boost_1_45_0/stage/lib'. Neither worked.
As requested the comiler error for the above code is:
**** Build of configuration Debug for project test ****
make all
Building file: ../src/test.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/test.d" -MT"src/test.d" -o"src/test.o" "../src/test.cpp"
../src/test.cpp:10:32: warning: boost/filesystem.hpp: No such file or directory
../src/test.cpp: In function 'int main()':
../src/test.cpp:13: error: 'boost' has not been declared
../src/test.cpp:13: error: expected `;' before 'path'
../src/test.cpp:14: error: 'boost' has not been declared
../src/test.cpp:14: error: 'path' was not declared in this scope
make: *** [src/test.o] Error 1
If any one has any further suggestions I am still trying.
Second Update
On a suggestion by rholmes I added an include library along with the linker list and library search path. So now the compile error is:
**** Build of configuration Debug for project test ****
make all
Building target: test
Invoking: MacOS X C++ Linker
g++ -L/Users/jacobschoen/Library/boost_1_45_0 -o "test" ./src/test.o -lboost_system -lboost_filesystem
ld: library not found for -lboost_system
collect2: ld returned 1 exit status
make: *** [test] Error 1
Any ideas?
Just wanted to be clear on what actually worked, since it was kinda pieced together from a few answers.
Download the boost files and extract them to where you want to put them.
In your terminal navigate to the directory and run ./bootstrap.sh
When that is done run ./bjam (this takes a while so go smoke and get a cup of coffee)
Open up your eclipse Project and go to Project > Properties > C/C++ Build > Settings
Click on MacOS X C++ Linker > Libraries.
You should see a split window with the top being for 'Libraries (-l)'. In this section add both boost_system and boost_filesystem. In the bottom section it should be for 'Library Search Path (-L)'. Here you want to put the path to the stage/lib directory inside where you extracted the boost download. It should look similar to below:
Click GCC C++ Compiler > Includes. This will be a single pane where it says 'Include Paths (-I)', well I think it is an I as he font is weird and could be a lower case l also. Anyway in that section add the path to where you put boost without the stage/lib part. It should look like below:
Everything should compile now with out a problem, and if you need to use any other boost libraries it should be just a matter of adding it to the linker section where boost_filesystem and boost_system are. Enjoy.
Not sure where you do this in Eclipse these days, but under the include paths for Eclipse should be the path to the main boost directory (/Users/jacobschoen/Library/boost_1_45_0?). The compiler line should have something like the following in it, I would think:
Invoking: GCC C++ Compiler
g++ -I/Users/jacobschoen/Library/boost_1_45_0 -O0 -g3 -Wall -c -fmessage-length=0 -MMD (etc..)
Update: Looking at my system, the linker path on yours might be more appropriately:
-I/Users/jacobschoen/Library/boost_1_45_0/stage/lib
Depending, of course, upon how you've installed and built boost -- this is with my most recent attempt with a full source build. Depending upon how you obtained boost, this may or may not be different. I recently redid the boost on my Mac for 64 bit and haven't had much time to try it yet....
Add boost_system to the linker list, together with boost_filesystem.
I had recently uninstalled the boost rpm and installed Boost like how you did. I had no problems running Boost programs in Eclipse. I didn't add any extra parameters. Just installed boost and ran Boost programs. It works fine.
Tried your program in the vi editor. Commented out everything in main
#include <cstdio>
#include <boost/filesystem.hpp>
int main() {
/*boost::filesystem::path path("/Users/schoen"); // random pathname
bool result = boost::filesystem::is_directory(path);
printf("Path is a directory : %d\n", result);*/
return 0;
}
and it still gave this error:
/tmp/cc7TAIYS.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x29): undefined reference to `boost::system::get_system_category()'
test.cpp:(.text+0x35): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x41): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x4d): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x59): undefined reference to `boost::system::get_system_category()'
collect2: ld returned 1 exit status
I'm puzzled. Boost programs work on my system, but your program's header files itself are giving a problem. I doubt it's a problem with Eclipse. It has to be something else.
I just ran into something very similar to this using eclipse and CDT... It turns out, using ubuntu and apt-get, libboost_system installs as libboost_system.1.40.0 in /usr/lib
If you try to add it via the library tab in Helios it will complain because it is looking for *.so and *.s0.1.40.0 clearly doesn't match that. However after looking closely at what the linker was trying to doo, I just typed the raw string "boost_system" into the include path adder. This resulted in the linker doing a " -lboost_system" which is a format the linker knows how to deal with in resolving version dependency... If you instead put in the full path to the .so file, the linker will just complain because it tries to do a " -l/usr/lib/libboost_system.so.1.40.0" .
So take my advice and just type in the simple " boost_system" after doing an apt-get install.. It will make it all very easy.

/usr/bin/ld: cannot find -llibeststring.a

I am using festival TTS c++ API in my program.I have downloaded all files from http://www.cstr.ed.ac.uk/downloads/festival/2.0.95/
and install festival and speech_tools successfully on my UBUNTU 10.04
now when compile my c++ programme gcc gives error:
g++ -L/usr/lib -L/home/peeyush/Desktop/festival/src/lib -L/home/peeyush/Desktop/speech_tools/lib -o"peeyush" ./src/peeyush.o -llibeststring.a -llibestbase.a -llibestools.a -llibFestival.a
/usr/bin/ld: cannot find -llibeststring.a
collect2: ld returned 1 exit status
make: *** [peeyush] Error 1
so please help me to sort out this error.
-Thanks
Peeyush Chandel(INDIA)
When using the -l option, you don't specify the leading lib or trailing .a or .so parts of the name as they're assumed by the linker. You would want to use something like -leststring to pick it up (assuming that your -L path is set correctly.
Alternately you can specify the exact filename (so no -l, just libeststring.a) as part of the object list to link (make sure the order is right relative to your .o files), but I believe in that case you would have to specify the path as the linker won't know to search your -L path. Easiest is to use -l though.