error when compiling c program with hdf4

/tmp/cc3jfEvc.o: In function `inputfield':
spectralmpi.c:(.text+0x44): undefined reference to `SDstart'
spectralmpi.c:(.text+0x56): undefined reference to `SDselect'
spectralmpi.c:(.text+0xc2): undefined reference to `SDreaddata'
spectralmpi.c:(.text+0x146): undefined reference to `SDend'
/tmp/cc3jfEvc.o: In function `Init':
spectralmpi.c:(.text+0x926): undefined reference to `SDstart'
spectralmpi.c:(.text+0x95e): undefined reference to `SDselect'
spectralmpi.c:(.text+0x99a): undefined reference to `SDgetinfo'
spectralmpi.c:(.text+0x9f0): undefined reference to `SDend'
/tmp/cc3jfEvc.o: In function `outputfield':
spectralmpi.c:(.text+0x3071): undefined reference to `DFR8addimage'
spectralmpi.c:(.text+0x3142): undefined reference to `SDstart'
spectralmpi.c:(.text+0x316a): undefined reference to `SDcreate'
spectralmpi.c:(.text+0x31ad): undefined reference to `SDsetcompress'
spectralmpi.c:(.text+0x3204): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x3211): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x321e): undefined reference to `SDend'
spectralmpi.c:(.text+0x32d5): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x32e2): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x32ef): undefined reference to `SDend'
spectralmpi.c:(.text+0x33df): undefined reference to `SDstart'
spectralmpi.c:(.text+0x33f6): undefined reference to `SDnametoindex'
spectralmpi.c:(.text+0x3408): undefined reference to `SDselect'
spectralmpi.c:(.text+0x3498): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x34a5): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x34b2): undefined reference to `SDend'
/tmp/cc3jfEvc.o: In function `plot':
spectralmpi.c:(.text+0x362a): undefined reference to `SDstart'
spectralmpi.c:(.text+0x363d): undefined reference to `SDend'
spectralmpi.c:(.text+0x37b3): undefined reference to `SDstart'
spectralmpi.c:(.text+0x385f): undefined reference to `SDcreate'
spectralmpi.c:(.text+0x3891): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x38a4): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x391a): undefined reference to `SDcreate'
spectralmpi.c:(.text+0x394c): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x395f): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x3972): undefined reference to `SDend'
collect2: ld returned 1 exit status

Have I installed hdf4 wrong?

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/error-when-compiling-c-program-with-hdf4-tp3506544p3506544.html
Sent from the hdf-forum mailing list archive at Nabble.com.

yea..
#include "hdf.h"
#include "dfsd.h"
#include "mfhdf.h"

Im not able to figure out what the problem is.

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/error-when-compiling-c-program-with-hdf4-tp3506544p3507304.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Hi there,

I'm sorry, but have you included the header file mfhdf.h?

Binh-Minh

···

-----Original Message-----
From: hdf-forum-bounces@hdfgroup.org [mailto:hdf-forum-bounces@hdfgroup.org]
On Behalf Of tomhagen1989
Sent: Monday, November 14, 2011 6:25 AM
To: hdf-forum@hdfgroup.org
Subject: [Hdf-forum] error when compiling c program with hdf4

/tmp/cc3jfEvc.o: In function `inputfield':
spectralmpi.c:(.text+0x44): undefined reference to `SDstart'
spectralmpi.c:(.text+0x56): undefined reference to `SDselect'
spectralmpi.c:(.text+0xc2): undefined reference to `SDreaddata'
spectralmpi.c:(.text+0x146): undefined reference to `SDend'
/tmp/cc3jfEvc.o: In function `Init':
spectralmpi.c:(.text+0x926): undefined reference to `SDstart'
spectralmpi.c:(.text+0x95e): undefined reference to `SDselect'
spectralmpi.c:(.text+0x99a): undefined reference to `SDgetinfo'
spectralmpi.c:(.text+0x9f0): undefined reference to `SDend'
/tmp/cc3jfEvc.o: In function `outputfield':
spectralmpi.c:(.text+0x3071): undefined reference to `DFR8addimage'
spectralmpi.c:(.text+0x3142): undefined reference to `SDstart'
spectralmpi.c:(.text+0x316a): undefined reference to `SDcreate'
spectralmpi.c:(.text+0x31ad): undefined reference to `SDsetcompress'
spectralmpi.c:(.text+0x3204): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x3211): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x321e): undefined reference to `SDend'
spectralmpi.c:(.text+0x32d5): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x32e2): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x32ef): undefined reference to `SDend'
spectralmpi.c:(.text+0x33df): undefined reference to `SDstart'
spectralmpi.c:(.text+0x33f6): undefined reference to `SDnametoindex'
spectralmpi.c:(.text+0x3408): undefined reference to `SDselect'
spectralmpi.c:(.text+0x3498): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x34a5): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x34b2): undefined reference to `SDend'
/tmp/cc3jfEvc.o: In function `plot':
spectralmpi.c:(.text+0x362a): undefined reference to `SDstart'
spectralmpi.c:(.text+0x363d): undefined reference to `SDend'
spectralmpi.c:(.text+0x37b3): undefined reference to `SDstart'
spectralmpi.c:(.text+0x385f): undefined reference to `SDcreate'
spectralmpi.c:(.text+0x3891): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x38a4): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x391a): undefined reference to `SDcreate'
spectralmpi.c:(.text+0x394c): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x395f): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x3972): undefined reference to `SDend'
collect2: ld returned 1 exit status

Have I installed hdf4 wrong?

--
View this message in context:
http://hdf-forum.184993.n3.nabble.com/error-when-compiling-c-program-with-hd
f4-tp3506544p3506544.html
Sent from the hdf-forum mailing list archive at Nabble.com.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

--
Internal Virus Database is out-of-date.
Checked by AVG.
Version: 7.5.549 / Virus Database: 270.9.0/1778 - Release Date: 11/9/2008
2:14 PM

I want to share with you one trick about hdf4. If you are compiling/
linking using both libmfhdf.a and libdf.a, be sure to put "-lmfhdf"
in front of "-ldf" in your command line. If instead you put "-df"
in front of "-lmfhdf", you may get errors like yours.

Please try if this helps for your problem. It took me a while to
figure out this trick. But I still do not know why.

···

----- Original Message -----
From: "tomhagen1989" <tomhagen1989@gmail.com>
To: hdf-forum@hdfgroup.org
Sent: Monday, November 14, 2011 5:25:12 AM
Subject: [Hdf-forum] error when compiling c program with hdf4

/tmp/cc3jfEvc.o: In function `inputfield':
spectralmpi.c:(.text+0x44): undefined reference to `SDstart'
spectralmpi.c:(.text+0x56): undefined reference to `SDselect'
spectralmpi.c:(.text+0xc2): undefined reference to `SDreaddata'
spectralmpi.c:(.text+0x146): undefined reference to `SDend'
/tmp/cc3jfEvc.o: In function `Init':
spectralmpi.c:(.text+0x926): undefined reference to `SDstart'
spectralmpi.c:(.text+0x95e): undefined reference to `SDselect'
spectralmpi.c:(.text+0x99a): undefined reference to `SDgetinfo'
spectralmpi.c:(.text+0x9f0): undefined reference to `SDend'
/tmp/cc3jfEvc.o: In function `outputfield':
spectralmpi.c:(.text+0x3071): undefined reference to `DFR8addimage'
spectralmpi.c:(.text+0x3142): undefined reference to `SDstart'
spectralmpi.c:(.text+0x316a): undefined reference to `SDcreate'
spectralmpi.c:(.text+0x31ad): undefined reference to `SDsetcompress'
spectralmpi.c:(.text+0x3204): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x3211): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x321e): undefined reference to `SDend'
spectralmpi.c:(.text+0x32d5): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x32e2): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x32ef): undefined reference to `SDend'
spectralmpi.c:(.text+0x33df): undefined reference to `SDstart'
spectralmpi.c:(.text+0x33f6): undefined reference to `SDnametoindex'
spectralmpi.c:(.text+0x3408): undefined reference to `SDselect'
spectralmpi.c:(.text+0x3498): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x34a5): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x34b2): undefined reference to `SDend'
/tmp/cc3jfEvc.o: In function `plot':
spectralmpi.c:(.text+0x362a): undefined reference to `SDstart'
spectralmpi.c:(.text+0x363d): undefined reference to `SDend'
spectralmpi.c:(.text+0x37b3): undefined reference to `SDstart'
spectralmpi.c:(.text+0x385f): undefined reference to `SDcreate'
spectralmpi.c:(.text+0x3891): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x38a4): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x391a): undefined reference to `SDcreate'
spectralmpi.c:(.text+0x394c): undefined reference to `SDwritedata'
spectralmpi.c:(.text+0x395f): undefined reference to `SDendaccess'
spectralmpi.c:(.text+0x3972): undefined reference to `SDend'
collect2: ld returned 1 exit status

Have I installed hdf4 wrong?

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/error-when-compiling-c-program-with-hdf4-tp3506544p3506544.html
Sent from the hdf-forum mailing list archive at Nabble.com.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

/tmp/cc3jfEvc.o: In function `inputfield':
spectralmpi.c:(.text+0x44): undefined reference to `SDstart'
spectralmpi.c:(.text+0x56): undefined reference to `SDselect'
spectralmpi.c:(.text+0xc2): undefined reference to `SDreaddata'
spectralmpi.c:(.text+0x146): undefined reference to `SDend'

...

collect2: ld returned 1 exit status

Have I installed hdf4 wrong?

Can't tell for sure from the errors you show. The linker
tells you that a number of hdf4 functions can't be found.
That makes it look a bit as if you don't link against the
required library (if the library wouldn't be installed in
a place the linker is looking for it you would get a com-
plaint about that instead). Does you have something like
'-lhdf4' (if you're on Unix) in the command for linking
the program?
                          Regards, Jens

···

On Mon, Nov 14, 2011 at 03:25:12AM -0800, tomhagen1989 wrote:
--
  \ Jens Thoms Toerring ________ jt@toerring.de
   \_______________________________ http://toerring.de

when i do -lhdf4 i get

/usr/bin/ld: cannot find -lhdf4
collect2: ld returned 1 exit status

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/error-when-compiling-c-program-with-hdf4-tp3506544p3507309.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Please try as Yongsheng Pan suggested:
-lmfhdf -ldf
on the link line.

···

-----Original Message-----
From: hdf-forum-bounces@hdfgroup.org [mailto:hdf-forum-bounces@hdfgroup.org]
On Behalf Of tomhagen1989
Sent: Monday, November 14, 2011 11:36 AM
To: hdf-forum@hdfgroup.org
Subject: Re: [Hdf-forum] error when compiling c program with hdf4

yea..
#include "hdf.h"
#include "dfsd.h"
#include "mfhdf.h"

Im not able to figure out what the problem is.

--
View this message in context:
http://hdf-forum.184993.n3.nabble.com/error-when-compiling-c-program-with-hd
f4-tp3506544p3507304.html
Sent from the hdf-forum mailing list archive at Nabble.com.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

--
Internal Virus Database is out-of-date.
Checked by AVG.
Version: 7.5.549 / Virus Database: 270.9.0/1778 - Release Date: 11/9/2008
2:14 PM