How to define environment variable when running a compiled program with scons - environment-variables

I did write my SConstruct file so I build and run the program by doing scons run
program = env.Program('build/output', Glob('build/test/*.cpp'))
env.Default(program)
env.Alias('run', program, program[0].abspath)
I can compile my program and run it without problem, but when I try to use glut and opengl in my program, I have the following error:
/home/tran/workspace/bobail/build/test/test
freeglut (/home/tran/workspace/bobail/build/test/test): failed to open display ''
After some search I found out that my compiled program need the environment variable DISPLAY to be set to DISPLAY=:0. I tried using Scons Export command but with no success so far.
Could somebody tell me how to do it.
EDIT: My program work fine if I execute it from command line instead of Scons environment.

I found out how to do it. You need to retrieve the DISPLAY global environment and import it in scons environment. This you use this environment to define the alias for running the program.
test_env = Environment()
test_env.Append(ENV = {'DISPLAY' : os.environ['DISPLAY']})
test = test_env.Program(build_path + '/test/test', Glob(build_path + '/test/*.cpp'))
test_env.Alias('check', test, test[0].abspath)

Related

Run lua file other than main in replit

I'm trying to run a lua file other than main on replit.com, and I'm not sure how to do that. I know in java you just type "java name_of_file" into the terminal but typing "lua name_of_file) doesn't work.
Here is a screenshot of what I'm trying to do:
Here is my code on replit, so you can try running it: https://replit.com/join/kxisutsa-suzm10
You are currently in console, use shell instead and use lua activity.lua to run the activity.lua file.

trying to run an .exe file in lua

recently i have been trying to run a script in lua that through os.execute() will execute a script in C# compiled into an executablethat is in the same directory as my script.
In my first attempt adding the entire directory until the executable worked:
os.execute("C:\\ServerTest\\test\\tex\\testcode.exe")
however I need this script to work on other computers, which means I can't add the entirely path to the file.I tried countless methods to execute the .exe file inside the same directory without using the entire path and none of the methods worked
os.execute("./testcode")
os.execute [[".\testcode.exe"]]
os.execute(".\\testcode.exe")
os.execute "testcode.exe"
I even tried to create an environment variable and run the entire directory from it xD
os.execute("set wTest=%cd%")
os.execute("%wTest%\\testcode.exe")
but nothing worked. I also tried to use io.popen() but didn't get results either (because the executable will close a computer process, it does not give any output :V)
does anyone know how I can do this?????

Atom Run F# script, Windows 7 error

I am trying to run F# script from Atom editor but kept on getting the following error:
Unable to run fsi is it in your path?
I've checked the environment variables and the path is set correctly and can run it from the command prompt. Also others suggested running Atom from command prompt, I did that but still the same. Is Atom looking for files in a case sensitive way? (If so that may be the issue as the F# interactive is "Fsi.exe").

ACE TAO cannot get NameService object in debug mode

I'm running a multi-program projects using ACE TAO. I set the Environment Variables and compiled ACE_TAO environment. Then I copied the tao_cosnaming.exe to my project run directory and use a .bat to start the naming service.
The programs run well if I start them directly, but they could not get the "NameService" correctly when I invoke obj = orb->resolve_initial_references("NameService") in debug mode. (I could not run obj->_non_existent(), it throws an error).
It seemed because the Naming Service is implemented as a remote one. When I invoke obj = orb->invoke resolve_initial_references("RootPOA"), things are fine, because RootPOA is local object so obj->_non_existent() return immediately.
The .bat file is like:
cd /D %DTAX_RUN_DIR%
tao_cosnaming -ORBEndPoint iiop://%DTAX_NAME_SERVICE_HOST%
The DTAX_RUN_DIR and DTAX_NAME_SERVICE_HOST are Environment Variables. DTAX_RUN_DIR is project run directory and DTAX_NAME_SERVICE_HOST=169.254.51.81:10493
Could anybody share some ideas on what is going wrong? Thanks!
It's hard to give a definite solution with just the information you provided, but in my projects I need to pass "-c" (without the quotes) as a command argument so that I can debug it, maybe you need to do the same.
In Visual Studio in the project properties you can find the Command arguments field in Properties/Debugging.

Generate reports using Clang Analyzer - scan-build

I am new to Clang analyzer and I am trying to generate reports using scan-build. While using the scan-build as below:
./scan-build --use-analyzer=/build/Debug+Asserts/bin/clang -v -o report_location sample.xcodeproj
I am always getting the below error:
scan-build: Using `/build/Debug+Asserts/bin/clang' for static analysis ; Can't exec "sample.xcodeproj":
Permission denied at ./scan-build line 1029. ;
scan-build: Removing directory 'report_location/2013-06-25-1' because it contains no reports. ;
scan-build: No bugs found.
Please help me resolving this issue.
The way scan build works is it either
invokes the command you provide e.g. make
executes the file that you provide e.g. some shell script
And when it does that it overrides the $CC environment variable to point to another script from where it forks two processes. In one the compiler runs as regular build and in another static-analyzer runs to generate report.
You are getting this error because 'sample.xcodeproj' is not an executable.
I'm not very familiar with xcode but I think if you chmod +x sample.xcodeproj then things should work.
clang-static analyzer can be integrated with xcode as well:
http://clang-analyzer.llvm.org/xcode.html
https://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode_User_Guide/000-About_Xcode/about.html#//apple_ref/doc/uid/TP40010215-CH3-SW17

Resources