0

Im creating a program in C and I am going to need some thermodynamics properties for water and steam. I have searched online and i found this library: http://freesteam.sourceforge.net

On their website they advise to compile using something called "scons". for that, i must have a file called SConstruct with the following code

# simple SCons script to build the example(s)

env = Environment()
import sys

import platform
if platform.system() == "Windows":
    # windows has problems, so we help it along a bit...
    cmd = [sys.executable,r'..\freesteam-config']
else:
    # on other platforms, it just works...
    cmd = ['freesteam-config']

env.ParseConfig(cmd + ['--libs','--cppflags'])

env.Program('test1',['test1.c'])

and run the line $ scons on the command line.

My big problem is that when i run a simple code, this part of the code doesn't seem to run properly:

    #include <freesteam/steam_ps.h>
    #include <freesteam/steam_pT.h>
    #include <freesteam/region4.h>
    #include <stdio.h>
    #include <math.h>
    #include <stdlib.h>

    t = d - (a-d)/(1 + pow((p[0]/c),b)); 

I just posted the libraries and the line that doesn't seem to work, since the rest is just printfs and scanfs. All those variables are doubles.

and then i get this error

ubuntu@ubuntu:~/Documents/test folder$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o test1 test1.o -L/usr/local/lib -lfreesteam
/usr/bin/ld: test1.o: undefined reference to symbol 'pow@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
scons: *** [test1] Error 1
scons: building terminated because of errors.

If anyone can help me with this, I would be grateful. I am not entirely sure, but I think it might be the pow() function. Although i have tried putting something like pow(2,2) and it works fine.

  • Could you edit title of your question to specify better the problem? It is too general at this moment – radrow Mar 11 '19 at 00:23
  • Please post the [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) that shows the problem. You might benefit by reading the [tour](https://stackoverflow.com/tour) and [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) – Weather Vane Mar 11 '19 at 00:27
  • 1
    Does gcc need an option to use the math library? `-lm` possibly? – Weather Vane Mar 11 '19 at 00:31
  • The posted code for the scons script is written in java not c nor c++ – user3629249 Mar 11 '19 at 01:22

1 Answers1

0

all libraries that are used need to be listed in the linker command.

this line:

gcc -o test1 test1.o -L/usr/local/lib -lfreesteam 

is missing the -lm at the end

Suggest:

gcc -o test1 test1.o -L/usr/local/lib -lfreesteam -lm
user3629249
  • 16,402
  • 1
  • 16
  • 17
  • I think it worked. Thank you (I put test1.c instead of test1.o) Just to be clear, with this code, I don't need the "scons" command? – Igor Stravinsky Mar 11 '19 at 20:59