Eclipse ignore LD_LIBRARY_PATH in Environment - c++

I'm trying to lunch an application from Eclipse CDT and as I read everywhere, I set LD_LIBRARY_PATH to the directory containing the shared library:
However, when I try to run this configuration:
/home/luca/Dropbox/HKUST/CloudCache/cloudcache/CloudCache/make/CloudCache: error while loading shared libraries: libvl.so: cannot open shared object file: No such file or directory
Just to clarify: I'm 100% sure that libvl.so is in that path, in fact when I try to run the application from command line it works perfectly.
Why this happens?

I wonder if it is being reset somewhere else. You can also set environment variable in the Launch Configuration if you are using that. There are two places in there, one where you have an 'Environment' tab, and another where you choose your 'Build Configuration' which could itself point somewhere else.
I've just been trying to get this to work for the first time in eclipse (Linux 64), and did exactly what you showed and it worked.

A bit late, but still can be useful. You have the option "Append environment to native environment" checked on your screenshot. Very probably you have this variable redefined there. It was my case.

Related

Set a predefined working directory when building a program in MacOSX

Recently I encountered this documentation about Apple and the loading of dynamic libraries.
Citing:
When the library name is a filename (that is, when it doesn’t include directory names), the dynamic loader searches for the library in several locations until it finds it, in the following order:
$LD_LIBRARY_PATH
$DYLD_LIBRARY_PATH
The process’s working directory
$DYLD_FALLBACK_LIBRARY_PATH
And my concern is about the third step "The process’s working directory".
Since I load libraries (and libraries that I load will load others), I would like to force the working directory to be some predefined path.
At the beginning of the main is already too late for me.
Do you know if there is some build option that I can set in pkgbuild, or in some .plist file?
Do you know a workaround for that?
EDIT:
I found these keys that could be set, in particular see LSEnvironment.
I was thinking maybe some 'hack' like
$DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$DYLD_FALLBACK_LIBRARY_PATH
(yes, I know that it is ugly...). But it would not work anyway, because citing the previous link:
These environment variables are set only for apps launched through Launch Services. If you run your executable directly from the command line, these environment variables are not set.
So, what can I do if someone calls my executable directly?
Are the .plist files considered at all in case the executable is called directly?

How do I turn my C++ code into a .app file? [duplicate]

I am building a C++ OpenGL card game in Xcode 4.3.3, with the intention of running it on both 64-bit and 32-bit Macs, which is not my problem. My problem is that I have reached a point in the development of the program where I would like to test that it works on a different 32-bit Mac (mine is 64-bit) without having to install Xcode. This, obviously, requires me exporting it as an .app. I can find and run the exported Unix Executable File from my project, after some cd'ing, through Terminal, but that is undesirable for me and the intended audience of the program. I have trawled the google and Stack Overflow, looking for anything to help me, but all the things mentioning Archiving seem to have been unsuccessful with my particular project, and I think that's because it's a C++ command line tool project. So, can someone please help me export my project as a .app?
Thanks in advance.
The simplest way of doing this would be to create a Cocoa project, go to 'build phases' and remove all the objective-c frameworks from the 'link with libraries' build phase, remove any objective-c files added by the template (app delegate, etc.) and then replace main.c with your main.cpp file.
There's nothing really special about a Cocoa project except for the fact that it links against Cocoa and calls NSApplicationMain() from its main() function.
There are also a bunch of .plist entries used by Cocoa which you'll no longer need. But they won't affect the way OS X treats your application.
I'm searching for an XCode Settings solution but here's my current way to create an app:
You have to take your binary file (let say myapp) and put it in "MyApp.app/Contents/MacOS/myapp" then it can now be launched as a .app. That's a trick.
Just go to the targets folder in the file navigator on the left, and there will be an executable listed there. Left click on that executable and click "show in finder". (I'm describing from memory so I may have the exact details wrong.) The file path is ridiculously long (there is an arbitrary alphanumerical pathname involved, I have no idea why), so you probably won't be able to find it with the command line.
If you want you can change the extension of the file from nothing to ".app", it shouldn't affect the nature of the file at all. Also if you want a custom icon, you can "get info" on it in the finder, then click on the icon in the info window, and use Cmd-V to paste it in (obviously you have to have your icon copied to the clipboard). There is also a way to do this inside of Xcode, but I don't remember it.

can't include Qt classes while creating project with VS-add in

I recently begin to use Qt and decided to use it with Visual Studio (2013).
The problem is that when i create the project the Qt classes even the most common can't be included (as QApplication) even if i had to it every Modules (core GUI...). Intellisense underline it in red saying :"cannot open source file QApplication". And when i try to run the project, it tells me that i missed some .dll. The weirdest thing is that i already manage (2 times) to make it worked, simply by creating the project without doing anything special(i think).
Moreover when i use the qtcreator it works fine but i'd like to use VS.
Sorry, i had a hard time being specific since i really don't have a clue.
In addition #drescherjm comment, you should also check that you have an system environment variable set - The variable name should be QTDIR and the path should be the path of your installation - on my system this is C:\Qt\Qt5.5.1\5.5\msvc2013.
OK, it seems i found a way to resolve the problem but i still don't get why.
It appears that if i go in the Qt options even if the path is already set, i need to select it and press ok. And then build the project and reopen it for intelisense to work. And it worked. But it's weird because i already fund the place where the qtdir variable is stored and it was alright but the project still didn't worked??

Netbeans/C++ add environment variable at make

I need to set a variable that is checked in the makefile(i.e. at compile time), but I can't find it in the project properties.
I right-click on the project, but can't find a place to set environment vars, except in the Run but even there it seems I can't add a variable (nothing happens when I click on Add after expanding the ...).
What am I missing?
As a side: Netbeans probably will run a shell before issuing the commands like make, what kind of shell is it? how can I configure it?
Judging by your screenshot that you are on OSX, you should be able to set an environment variable by replacing "${OUTPUT_PATH}" under Run Directory with FOO=BAR;"${OUTPUT_PATH}". This is normal POSIX syntax for running a program with a specific environment variable or set of variables set, and can be used at the terminal as well.
Edit: In Netbeans, to set an environment variable for a specific action, right click on project, go to Properties->Actions->{Action}->Set Properties: Add Env.FOO=BAR.

How would I build Box2D to work in Code::Blocks/Mingw32(Windows)

hey the title pretty much says it all. i have been trying different methods from internet sources, but whenever i try something goes wrong..this is where i got Box2D
in cMake, i get a bunch of errors when building it(i was going through the steps in the readme.txt, but onfortunately, theyre for Visual C++...)
so im wondering hot to set this up as i guess a library (.lib or .a) and use it in my project(my friend passed me his library and when i loaded it in and tried #includeing the box2D headers, they didnt read at all(i got a list of undefined errors) also his box2d was i believe made for linux/unix so i think thats the reason...)
if anyone can help provide some steps that would be nice.
thanks for reading.
Assumptions:
You have installed cmake.
You have installed Code::Blocks/MinGW to C:\codeblocks.
You have downloaded Box2D and extracted it to C:\Box2D_v2.1.2.
If any of those are wrong, modify the paths to match what you have.
Start->Run->cmd.
Navigate to the Box2D "Build" folder:
cd C:\Box2D_v2.1.2\Box2D\Build
Create the makefiles:
cmake -G "MinGW Makefiles" ..
Do it:
mingw32-make
This will throw some warnings, but should work almost completely. Then, near the end, it will error trying to compile the Testbed. AFAIK, there is no way to compile the Testbed using MinGW (you have to use Visual Studio, I believe). Luckily, an .exe of it is available on the Box2D site.
In the Box2D\Build\Box2D folder, there should now be a file called libBox2D.a. Copy this file into C:\codeblocks\mingw\lib.
Copy the Box2D\Box2D folder (the one containing Box2D.h) into C:\codeblocks\mingw\include.
[Thus, after this step, you should have a file C:\codeblocks\mingw\include\Box2D\Box2d.h, and NOT C:\codeblocks\mingw\include\Box2d.h]
And that's it. You should be able to compile and run the "Hello Box2D" example. Don't forget to link to the library.
[EDIT]
From the looks of your error, I'm going to guess that your MinGW Path environment variable is not setup correctly. Which is unusual, since when you install Code::Blocks/MinGW it usually sets it for you, I believe.
Anyway, (these steps may vary slightly depending on your version of Windows):
Right-click on "[My] Computer"-> Properties -> Advanced System Settings
Click "Environment Variables"
Depending on which Windows you have, you may see User Variables and System Variables, or it may be just one group (I can't remember the name). Anyway, create a new System Environment Variable called MINGDIR, with the value C:\codeblocks\mingw or wherever you installed it to. Then, find the variable called Path (or PATH) and append this to the end: C:\codeblocks\mingw\bin. Put a semicolon at the end of the previous entry, and do not use a space.
Also make sure that C:\CMake\bin is present in either the System Variable called Path, or the user variable called Path. If not, append it to the end.
I think that's it.