Scons "Dir" command doesn't work? - variables

I've got a sub directory called "myc" containing 2 ".c" files:
$ ls myc
1.c f.c
And my current directory has a SConstruct:
$ cat SConstruct
myc=Dir('myc')
print myc
Program('test2',myc)
Run scons, it prints a bunch of errors:
$ scons
scons: Reading SConscript files ...
myc
scons: done reading SConscript files.
scons: Building targets ...
gcc -o test2 myc
/usr/bin/ld: cannot find myc: File format not recognized
collect2: error: ld returned 1 exit status
scons: *** [test2] Error 1
scons: building terminated because of errors.
What is weird: I expect the "print myc" will list "1.c" and "f.c", to my disappointment it prints "myc", not the varible value, and the compiling also fails.
How to correct it?

Not sure why you believe that specifying a directory as the source(s) for a directory would work?
Is there something in the docs which makes you believe this should work?
If so, please point it out so it can be improved.
If you did:
gcc -o blah some_dir_name
That wouldn't work right?
This should do what you're asking for.
myc=Glob('myc/*.c')
print myc
Program('test2',myc)

Related

Compilation errors when trying to do scons in util/tlm

I was trying to follow the README under util/tlm. Below are the steps completed:
scons build/ARM/gem5.opt - completed
scons --with-cxx-config --without-python --without-tcmalloc USE_SYSTEMC=0 build/ARM/libgem5_opt.so - completed
cd util/tlm
scons - error
when I do scons from within util/tlm I see the following error:
scons: Reading SConscript files ...
Checking whether __i386__ is declared... (cached) no
Checking whether __x86_64__ is declared... (cached) yes
scons: done reading SConscript files.
scons: Building targets ...
g++ -o build/tlm/sc_master_port.o -c -std=c++17 -DSC_INCLUDE_DYNAMIC_PROCESSES -DTRACING_ON -I/home/gem5/build/ARM -I/home/gem5/util/systemc/gem5_within_systemc -I/home/gem5/ext/systemc/src -Isrc -Iexamples/common build/tlm/sc_master_port.cc
build/tlm/sc_master_port.cc: In member function 'void Gem5SystemC::SCMasterPort::b_transport(tlm::tlm_generic_payload&, sc_core::sc_time&)':
build/tlm/sc_master_port.cc:278:32: error: 'gem5::sim_clock' has not been declared
(double)(ticks / gem5::sim_clock::as_int::ps), sc_core::SC_PS);
^~~~~~~~~
scons: *** [build/tlm/sc_master_port.o] Error 1
scons: building terminated because of errors.
Can you please help me out with how to resolve this?
For the above bug, I added #include "sim/core.hh" in the file "util/tlm/src/sc_master_port.cc"
Post that there are some namespace errors in few different files which I resolved by adding "using namespace gem5"

Making Cmakelist (ros) failure

After installing ros(melodic version), I followed the below steps one by one.
$ mkdir -p catkin_ws/src
$ cd catkin_ws/src
$ catkin_init_workspace
$ cd ..
$ catkin_make
Then error came up like this
CMake Error at CMakeLists.txt:1:
Parse error. Expected a command name, got unquoted argument with text
"/opt/ros/melodic/share/catkin/cmake/toplevel.cmake".
-- Configuring incomplete, errors occurred!
See also "/home/hangilkim/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/hangilkim/catkin_ws/build/CMakeFiles/CMakeError.log".
Makefile:320: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed
I found that CMakeLists.txt file in 'home/catkin_ws/src' folder exists clearly, but contain only this message.
/opt/ros/melodic/share/catkin/cmake/toplevel.cmake
How can I solve this problem??
Looks like you are trying to compile an already compiled project. So delete the CMakeLists.txt file in 'home/catkin_ws/src' or for safety measures move it to another folder then run catkin_make command on your terminal.

g++.exe: #letstr.txt: No such file or directory g++.exe: no input files -first try-

as you know that i'm really a beginner for CodeLite and MinGW, and i don't have any idea how it's works. When i try to build the project, the output said that it's error and i don't know what should i do. I'm using Windows 10.
i simply just follow the steps based on this video for the first try. https://www.youtube.com/watch?v=LGGHxaDxSK4
when i want to apply for some installation, the bar always show up like this
http://sta.sh/015gez4rfjn0
i even try to mark mingw32-gcc-g++
let me show you my output
C:\Windows\system32\cmd.exe /C C:/MinGW/bin/mingw32-make.exe -j4 SHELL=cmd.exe -e -f Makefile
"----------Building project:[ letstr - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/asu/Documents/letstry/letstr'
C:/MinGW/bin/g++.exe -o ./Debug/letstr #"letstr.txt" -L.
g++.exe: #letstr.txt: No such file or directory
g++.exe: no input files
mingw32-make.exe[1]: *** [Debug/letstr] Error 1
letstr.mk:78: recipe for target 'Debug/letstr' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/asu/Documents/letstry/letstr'
Makefile:4: recipe for target 'All' failed
mingw32-make.exe: *** [All] Error 2
====1 errors, 0 warnings====
g++.exe: #letstr.txt: No such file or directory
i think your destination file incorrect. if you create C program it must be named with .c extension instead of .txt.

Using WiringPi C library through SSH on Netbeans

How can I use WiringPi library through SSH on Netbeans? When I run a simple HelloWorld program, it works.
This is the output message:
Copying project files to /root/.netbeans/remote/RASPBERRYPI/win-7pjgqkgjsj4-Windows-x86_64 at root#RASPBERRYPI
Building project files list...
Checking directory structure...
Checking previously uploaded files...
Checking links...
Uploading changed files:
Zipping 10 changed files...
Uploading zip to root#RASPBERRYPI...
Unzipping changed files...
Checking exec permissions...
Uploading changed files finished successfully.
cd '/root/.netbeans/remote/RASPBERRYPI/win-7pjgqkgjsj4-Windows-x86_64/C/Users/Public/Remote Projects/BlinkingLED'
/usr/bin/make -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/root/.netbeans/remote/RASPBERRYPI/win-7pjgqkgjsj4-Windows-x86_64/C/Users/Public/Remote Projects/BlinkingLED'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/blinkingled
make[2]: Entering directory '/root/.netbeans/remote/RASPBERRYPI/win-7pjgqkgjsj4-Windows-x86_64/C/Users/Public/Remote Projects/BlinkingLED'
mkdir -p build/Debug/GNU-Linux
rm -f "build/Debug/GNU-Linux/main.o.d"
gcc -c -g -std=c11 -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.c
mkdir -p dist/Debug/GNU-Linux
gcc -o dist/Debug/GNU-Linux/blinkingled build/Debug/GNU-Linux/main.o
build/Debug/GNU-Linux/main.o: In function `main':
/root/.netbeans/remote/RASPBERRYPI/win-7pjgqkgjsj4-Windows-x86_64/C/Users/Public/Remote Projects/BlinkingLED/main.c:24: undefined reference to `wiringPiSetup'
/root/.netbeans/remote/RASPBERRYPI/win-7pjgqkgjsj4-Windows-x86_64/C/Users/Public/Remote Projects/BlinkingLED/main.c:29: undefined reference to `pinMode'
/root/.netbeans/remote/RASPBERRYPI/win-7pjgqkgjsj4-Windows-x86_64/C/Users/Public/Remote Projects/BlinkingLED/main.c:32: undefined reference to `digitalWrite'
/root/.netbeans/remote/RASPBERRYPI/win-7pjgqkgjsj4-Windows-x86_64/C/Users/Public/Remote Projects/BlinkingLED/main.c:34: undefined reference to `delay'
/root/.netbeans/remote/RASPBERRYPI/win-7pjgqkgjsj4-Windows-x86_64/C/Users/Public/Remote Projects/BlinkingLED/main.c:35: undefined reference to `digitalWrite'
/root/.netbeans/remote/RASPBERRYPI/win-7pjgqkgjsj4-Windows-x86_64/C/Users/Public/Remote Projects/BlinkingLED/main.c:37: undefined reference to `delay'
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/GNU-Linux/blinkingled' failed
make[2]: *** [dist/Debug/GNU-Linux/blinkingled] Error 1
make[2]: Leaving directory '/root/.netbeans/remote/RASPBERRYPI/win-7pjgqkgjsj4-Windows-x86_64/C/Users/Public/Remote Projects/BlinkingLED'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/root/.netbeans/remote/RASPBERRYPI/win-7pjgqkgjsj4-Windows-x86_64/C/Users/Public/Remote Projects/BlinkingLED'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
This is a quite old post, but since I've had the same problem and I've resolved it I'm now writing down the solution, so if someone needs it, it's ready ;)
The only thing to do is to add some parameters to the compilation command, in particular the path to binaries and includes plus the -lwiringpi option.
To do that in NetBeans, rightclick on the project, then properties. From there, Build->C Compiler.
Now, find the voice Additional Options, open it and copy paste the following:
-I/usr/local/include -L/usr/local/lib -lwiringPi
(that are the paths to the standard installation of wiringPi, if you have changed the location of the library change the paths accordingly)
Now it should work, at least it worked for me.
Hope it helped someone,
Bye
EDIT:
I forgot to add that you must ssh as root user, otherwise wiringPi doesn't work.
For that you must do:
passwd root
to set root password
sudo nano /etc/ssh/sshd_config
And change PermitRootLogin to yes
reboot

gfortran cannot read its own creation

I am trying to compile a code with gfortran. One of the first things that happens in the compilation is the creation of constants.mod. Soon after that gfortran tells me:
Fatal Error: Cannot read module file ‘constants.mod’ opened at (1), because it was created by a different version of GNU Fortran
Now here's the thing: This module file is created by the same gfortran that it's trying to read it. gfortran creates the thing itself and then 1 second later thinks the file was created by some other version! Any idea what's going on here?
You'll probably want to see the compile command:
mpif90 -c -O3 -ISDF/FORTRAN/include -I/usr/include -Iobj -Jobj -o obj/shared_data.o src/core/shared_data.F90
shared_data.F90 contains the module constants at the top of the file.
EDIT: Here's the compile command followed by the full error message:
$> mpif90 -c -O3 -ISDF/FORTRAN/include -I/usr/include -Iobj -Jobj -o obj/shared_data.o src/core/shared_data.F90
src/core/shared_data.F90:67:6:
USE constants
1
Fatal Error: Cannot read module file ‘constants.mod’ opened at (1), because it was created by a different version of GNU Fortran
compilation terminated.
UPDATE: I hope you'll agree this is weird. The file that is failing is in src/core. If I cd to src/core and issue this command:
mpif90 -c -O3 -I../../SDF/FORTRAN/include -I../../obj -J../../obj -o ../../obj/shared_data.o shared_data.F90
it compiles just fine! But then I clean everything out of the obj directory and I cd two levels up and issue:
mpif90 -c -O3 -ISDF/FORTRAN/include -Iobj -Jobj -o shared_data.o src/core/shared_data.F90
and it fails with the error I showed above! What is the difference??? Thanks.