User forums > Using Code::Blocks
Setting Code::Blocks for static compilation - Linux
(1/1)
Datatag:
Hello All
This is my first post and I'm new to both C++ programming and Code:Blocks, so please be gentle!
I'm trying to write and compile a serial comms console program under Linux, using ncurses and libSerial, that can then be run on another "vanilla" Linux machine - both machines are running Debian Wheezy 7.3 and the coding is done using Code::Blocks 13.12. The reason behind this is that I do my coding on a desktop PC at home, and need to run the code on a small laptop PC.
The program compiles and runs fine on the original machine but when I transfer the executable to the second machine, I get an "Error opening terminal: xterm" message - xterm is installed on both machines!
My includes are as follows:
--- Code: ---#include <cstdlib>
#include <ncurses.h>
#include <SerialStream.h>
#include <cstring>
#include <iostream>
--- End code ---
and I've made sure that the ncurses and libSerial libraries are included in the Link Libraries list in Project -> Build Options -> Linker Settings.
Another post recommended setting the "-static" and "-static-libgcc" options under Other Linker Options in Project -> Build Options -> Linker Settings and whilst my Debug executable increases in size from ~320K to ~1.6M, I get the same error! I also tried running the executable on another machine running Ubuntu 12.10, but got the same result.
Can anyone advise if what I want to do is feasible and, if so, how to set up C::B to achieve the required result.
Thanks in advance,
Derek.
BlueHazzard:
why do you get this error? are you trying to run the program from c::b?
try to run xterm from the command line...
greetings
Datatag:
Hi BlueHazzard
Thanks for your reply.
--- Quote ---why do you get this error? are you trying to run the program from c::b?
--- End quote ---
On my compilation PC (with C::B and the libraries installed) I can run the program either from within C::B (F9) or by opening a terminal in the compiler's output directory (Debug or Release) and doing ./<progname>. On the other PCs I've tried opening a terminal in the relevant directory and doing ./<progname>, but get the error message.
--- Quote ---try to run xterm from the command line...
--- End quote ---
Running xterm from the command line opens xterm, so it seems to be installed OK. I've tried doing both xterm <progname> and xterm -T <progname> within a terminal and xterm opens, but just comes back with the command prompt.
Some other non-ncurses C++ programs (using standard I/O) run just fine on my other PC, so I'm guessing I've probably missed something in the Compiler or Linker options in C::B!
Any help would be appreciated!
Kind Regards
Derek.
BlueHazzard:
i don't get it why ncurses/ some serial library needs xterm...
are you using a system() call?
anyway this doesn't seems to be a c::b related question, but a user/ library problem and with this, this forum is not the right place...
greetings.
Datatag:
Hi BlueHazzard
--- Quote from: BlueHazzard on March 10, 2014, 06:39:01 pm ---i don't get it why ncurses/ some serial library needs xterm...
are you using a system() call?
--- End quote ---
Good point - I have a function which displays the available serial ports by running a shell function to list the contents of /dev, grepping for ttySx and ttyUSBx and showing on the console. I'll try commenting that out and see if it makes a difference.
--- Quote ---anyway this doesn't seems to be a c::b related question, but a user/ library problem and with this, this forum is not the right place...
--- End quote ---
You're probably right, but this is fairly new to me as I've only written and compiled code for Arduino & Chipkit on their respective IDEs. I wasn't sure whether it was a coding issue, or some configuration thing in C::B!.
Thanks anyway.
Kind Regards
Derek.
Navigation
[0] Message Index
Go to full version