LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 05-20-2009, 11:30 AM   #1
kirit.makwana
LQ Newbie
 
Registered: May 2009
Posts: 3

Rep: Reputation: 0
How to include files from other directories in a program?


Hi all,
I have a fortran 77 code that has a statement

include 'netcdf.inc'


The file 'netcdf.inc' is in another directory /Users/makwana/Desktop/CDF/include

When i compile this program I get:

KirirtMakwana:F77 makwana$ gfortran -c simple_xy_wr.f
Error: Can't open included file 'netcdf.inc'
Error: Can't open included file 'netcdf.inc'

I gave the full path to the file in the program as follows:

include '/Users/makwana/Desktop/CDF/include/netcdf.inc'

and then it compiles but gives the following error when linking:
KirirtMakwana:F77 makwana$ gfortran -o outs simple_xy_wr.o
Undefined symbols:
"_nf_def_dim_", referenced from:
_MAIN__ in simple_xy_wr.o
_MAIN__ in simple_xy_wr.o
"_nf_enddef_", referenced from:
_MAIN__ in simple_xy_wr.o
"_nf_create_", referenced from:
_MAIN__ in simple_xy_wr.o
"_nf_close_", referenced from:
_MAIN__ in simple_xy_wr.o
"_nf_put_var_int_", referenced from:
_MAIN__ in simple_xy_wr.o
"_nf_def_var_", referenced from:
_MAIN__ in simple_xy_wr.o
"_nf_strerror_", referenced from:
_handle_err_ in simple_xy_wr.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

I want to know how to specify the full path of 'netcdf.inc' to the program from the command line?

Thanks,
Kirit.
 
Old 05-20-2009, 11:33 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: OpenSUSE 12.1 CentOS 6.2
Posts: 9,002

Rep: Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349
Use the -I option to compile:
Code:
gfortran -I/Users/makwana/Desktop/CDF/include -c simple_xy_wr.f
and leave only netcdf.inc in the include statement.
 
Old 05-20-2009, 01:26 PM   #3
kirit.makwana
LQ Newbie
 
Registered: May 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks, that worked
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing include directories - /usr/local/include quep_fly Linux - Newbie 6 08-12-2007 04:36 PM
rsync - How to Include Hidden (.something) Files and Directories? edwin11 Linux - Software 4 11-29-2006 07:47 AM
Program that determines which files/directories are taking up the most space kaplan71 Linux - Software 1 02-09-2006 07:21 AM
How to include library directories? davee Programming 7 04-05-2004 05:41 AM
Where to find/How to change .h include directories for g++ sfcesario Linux - Software 1 01-31-2004 10:12 AM


All times are GMT -5. The time now is 03:27 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration