Author Topic: Setting Code::Blocks for static compilation - Linux  (Read 7352 times)

Offline Datatag

  • Single posting newcomer
  • *
  • Posts: 4
Setting Code::Blocks for static compilation - Linux
« on: March 09, 2014, 12:42:50 pm »
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>

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.
« Last Edit: March 09, 2014, 06:49:06 pm by Datatag »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Setting Code::Blocks for static compilation - Linux
« Reply #1 on: March 09, 2014, 07:20:34 pm »
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

Offline Datatag

  • Single posting newcomer
  • *
  • Posts: 4
Re: Setting Code::Blocks for static compilation - Linux
« Reply #2 on: March 09, 2014, 08:21:18 pm »
Hi BlueHazzard

Thanks for your reply.

Quote
why do you get this error? are you trying to run the program from c::b?

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...

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.

« Last Edit: March 09, 2014, 08:23:05 pm by Datatag »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Setting Code::Blocks for static compilation - Linux
« Reply #3 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?
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.

Offline Datatag

  • Single posting newcomer
  • *
  • Posts: 4
Re: Setting Code::Blocks for static compilation - Linux
« Reply #4 on: March 10, 2014, 07:02:59 pm »
Hi BlueHazzard

i don't get it why ncurses/ some serial library needs xterm...
are you using a system() call?

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...
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.