Hi

I have modified the path to

dyn.load(paste(Sys.getenv("R_LIBS_USER"),"/fortran/src/fortran.so",sep=""))


and the package could installed, loaded and the lines with dyn.load worked.
It does not look like a pretty solution but works on my linux (I am not sure
if it works on my mac or windows).

I am not sure if this is what you meant but as I have no clue what
.First.lib does or NAMESPACES means this is the best I come up with.

Please correct me if I am wrong.

Many thanks

Ed



On Fri, Aug 19, 2011 at 6:03 PM, Uwe Ligges <ligges@statistik.tu-dortmund.de
> wrote:

>
>
> On 19.08.2011 22:53, Eduardo Mendes wrote:
>
>> Dear R-users
>>
>> I am slowly migrating my mex files (MATLAB - Fortran and C) to R.  To get
>> my
>> own functions available on R section I have decided to learn how to build
>>  a
>> R package. I choose a simple example with a few Fortran and R functions
>> (wrapper).
>>
>> The fortran sources are located at src and the R functions at R (as
>> recommended).  The building process went ok but R CMD check did not. The
>> error mgs was
>>
>> Error in dyn.load("fortran.so") :
>>   unable to load shared object
>> '/home/eduardo/R_packages/**test.Rcheck/fortran.so':
>>
>> Although I can see that R cannot find the compiled fortran code I do not
>> know what to do.   I believe it is something to do with the following
>> lines
>> in  the R-wrapper file
>>
>> if (!is.loaded('calnpr'))
>>                    dyn.load("fortran.so")
>>
>
>
> 1. If the package is called calnpr, the shared library is also called that
> way.
> 2. you have to provide the path to the shared library.
>
> See ?.First.lib for how to do it in a package without NAMESPACE (and note
> that NAMESPACES are forced for the next R release).
>
> Best,
> Uwe Ligges
>
>
>  How to add the path so that once the package is installed the compiled
>> fortran code can be found?
>>
>> Many thanks
>>
>> Cheers
>>
>> Ed
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________**________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

	[[alternative HTML version deleted]]

