scons build in eclipse - eclipse

I have converted a static library project and an exe project to Scons project in ECLIPSE. These were building fine by Makefile.
But when I am building the static library project it gives an error as below -
=== Running SCons at 18/11/13 8:55 PM ====
Command line: /usr/bin/scons -u --jobs=8
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: Debug
o Debug/add.o -c add.cpp
sh: o: not found
ar rc Debug/libadd.a Debug/add.o
ar: Debug/add.o: No such file or directory
scons: *** [Debug/libadd.a] Error 1
scons: building terminated because of errors.
Duration 301 ms.
1) my main objective is to a trigger a build once somehow (in the exe project) and both the project will be compiled in ECLIPSE. Is there a way to see and edit a SConscript in eclipse.
2) How do I do it? By manually writing SConscript and SConstruct file? :(

It looks from the SCons output like SCons can't find the compiler on your system. What OS are you using? And what version of SCons? (Type scons --version to see that.)

Related

SCons env.Command() doesn't work as expected, no command executed

I've got a simple SConstruct file as below:
import os,sys
env = Environment()
env.Command([], [], "echo abc")
I expected that this will output "abc", but in fact, nothing extra is printed, the screen output is:
$scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
So how should I fix it? Thanks a lot.
Since you've called a builder with no source and no targets, it's never out of date, and so won't be run.
So you want it to run right away, in which case you should use Execute()
env = Environment()
env.Execute("echo abc")
or just
Execute("echo abc")
The latter yields
$ scons
scons: Reading SConscript files ...
echo abc
abc
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.

error while loading shared libraries: libopencv_core.so.3.1

A bit confused. I set up all required lib paths and still have loading shared libraries error.
From the terminal when I type
>>pkg-config --libs opencv
-L/usr/local/lib -lopencv_cudabgsegm -lopencv_cudaobjdetect -lopencv_cudastereo -lopencv_shape -lopencv_stitching -lopencv_cudafeatures2d -lopencv_superres -lopencv_cudacodec -lopencv_videostab -lopencv_cudaoptflow -lopencv_cudalegacy -lopencv_calib3d -lopencv_features2d -lopencv_objdetect -lopencv_highgui -lopencv_videoio -lopencv_photo -lopencv_imgcodecs -lopencv_cudawarping -lopencv_cudaimgproc -lopencv_cudafilters -lopencv_video -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_cudaarithm -lopencv_core -lopencv_cudev
Inside the file
sudo gedit /etc/ld.so.conf.d/opencv.conf
I have /usr/local/lib
Then in Eclipse, I set up all include and lib paths as shown in the attached images.
Then build the project has no error.
But when I debug, the error is
error while loading shared libraries: libopencv_core.so.3.1: cannot open shared object file: No such file or directory
What could be wrong?
Thanks
As batuman posted on Feb 2 at 10:10, run at terminal:
sudo ldconfig
Verified 9 Sept 2016, Ubuntu 16.04.1, Eclipse Luna and Opencv 3.1

How to use SCons lex builder with variant directories

I'm trying to build a complex application with flex lexer using SCons. To build debug/release variants I'm using VariantDir().
The problem is that I can't force lex builder to generate lexer header in variant build directory. It isn't a big problem itself but it forces SCons to think that lexer is always out of date.
SConstruct contents:
VariantDir('build', '.', duplicate=0)
SConscript('build/SConscript')
SConscript contents:
env = Environment(LEXFLAGS='--header-file=scanner.h')
env.Program(target='scanner', source='scanner.l')
Full source to represent this problem is here: https://gist.github.com/g7r/4257f273715cadcf0d36
First scons.py --debug=explain run gives us this:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build
scons: building `build/scanner.c' because it doesn't exist
flex --header-file=scanner.h -t scanner.l > build/scanner.c
scons: building `build/scanner.o' because it doesn't exist
gcc -o build/scanner.o -c build/scanner.c
scons: building `build/scanner' because it doesn't exist
gcc -o build/scanner build/scanner.o
scons: done building targets.
Second run gives this:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build
scons: building `build/scanner.h' because it doesn't exist
flex --header-file=scanner.h -t scanner.l > build/scanner.c
scons: done building targets.
So second run rebuilds the lexer because scanner.h was generated in root directory instead of build directory.
Am I doing something wrong? Is there any way to do it right?
Consider combining the call to VariantDir() with the call to SConscript() which usually makes the paths in the build scripts more intuitive. Also, I suspect (unfortunately) the call to VariantDir() is confusing the SCons flex builder.
Here is an example:
SConscript('SConscript', variant_dir='build', duplicate=0)
Chapters 14 and 15 of the SCons user's guide give a good explanation of the SConscript() function.
For anyone hitting this old problem via a search - the problem isn't variant dirs per se, it's the use of the --header-file option and being in a subdirectory: SCons passes LEXFLAGS on as is when flex is called, but also extracts the header file name you asked for and adds it as a target - at which point it's subject to the SCons path interpretation rules, as in "relative to the directory of the SConscript", so flex generates the file one place via the issued command and SCons thinks it's a different place, thus the "always out of date". There's more on this topic at https://github.com/SCons/scons/issues/4154.

Issues with g++ and Eclipse on Linux - unresolved symbols

I am running Ubuntu 64bit version, and downloaded the latest 64bit Eclipse.
Installed g++ along with build-essential. Tested g++ to make sure it works from terminal, and it works fine.
alex#ubuntu:~/Desktop$ g++ test.cpp -o test
alex#ubuntu:~/Desktop$ ./test
Hello World!alex#ubuntu:~/Desktop$
However, trying to build simple C++ Hello Word project(one of the default projects that comes with Eclipse), I am getting error.
Description Resource Path Location Type
Program "g++" not found in PATH Preferences, C++/Build/Settings/Discovery, [CDT GCC Builtin Compiler Settings] options C/C++ Scanner Discovery Problem
I have added Environment variable named g++ with value /usr/bin/g++ and the above error went away, however, now I am getting unresolved errors, though project compiles and in the Console shows !!!Hello World!!!
Description Resource Path Location Type
Symbol 'endl' could not be resolved test_hello.cpp /test_hello/src line 13 Semantic Error
Symbol 'cout' could not be resolved test_hello.cpp /test_hello/src line 13 Semantic Error
Symbol 'std' could not be resolved test_hello.cpp /test_hello/src line 10 Semantic Error
Have I correctly entered Environmental variable ?? How can I get fix the "unresolved" error ?? Thanks !
When compiling there are two important things to consider:
1.) Is my path up-to-date with executables?
2.) Is my library path correct?
It appears you satisfy 1.) but not 2.)
The unresolved symbol error means that Eclipse cannot find your library via LD_LIBRARY_PATH or some other medium. It's attempting to locate the standard compiled C++ library.
How did you install g++?
Kindly do this and post the results:
Project > Properties > C/C++ Build > Environment
If everything there appears nominal, you can try
/sbin/ldconfig
which should hopefully re-parse your system library paths and might update your environment.

Eclipse Arduino make: *** error 1

Below is the error that I get when I try to build my project. I am unsure what file or directory it is talking about. All the files and directories are within the project directory.
I followed the instructions in http://arduino.cc/playground/Code/Eclipse to set up my IDE.
Should the Arduino core files be within the project directory and specifically added to the Arduino core library? All I gave it was the liArduinoCore.a file that was produced by my Arduino IDE. Could this be the issue?
The error message
**** Build of configuration Debug for project CustomLEDPoi ****
make all
Building target: CustomLEDPoi.elf
Invoking: AVR C++ Linker
avr-gcc -Wl,-Map,CustomLEDPoi.map,--cref Wl,--gc-sections - L"C:\Users\Justin\workspaceArduino\arduino_core\src" -L"C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src" -L"C:\Users\Justin\workspaceArduino\CustomLEDPoi\arduinolib" -L"C:\Users\Justin\workspaceArduino\CustomLEDPoi\lib" -mmcu=atmega328p -o "CustomLEDPoi.elf" ./src/glowstick2.o ./lib/CShiftPWM.o ./lib/MeetAndroid.o ./lib/hsv2rgb.o ./arduinolib/HardwareSerial.o ./arduinolib/SPI.o -lArduinoCore
avr-gcc.exe: Wl,--gc-sections: No such file or directory
make: *** [CustomLEDPoi.elf] Error 1
**** Build Finished ****
It seems that a - is missing for Wl,--gc-sections. It should actually be -Wl,--gc-sections. Without the proper flag, the compiler assumes that it's a source file. You should check the makefile and verify.