Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12600 Discussions

Include Library in project

Altera_Forum
Honored Contributor II
1,349 Views

Hi all, 

because I couldn't find anything on the net so far, I'm posting my problem here. 

I'm trying to pack parts of my NIOS-Code as a library and include it in another project using following documentation: 

[Sorry, but i am not allowed to post links by now] 

n2sw_nii52017.pdf from altera 

All I have to do is described on Page 25. 

 

The creating part of the library is working very well, but I'm not able to use it, because the compiler won't find it. I even created a very simple lib containing only one function, which litteraly does nothing. 

 

I even copied my library directly to the root of my project, which is trying to use it. 

 

Edit: 

My System: 

I am using the NiosII-Eds provided with Quartus 9.1sp2 on WindowsXP. I have full administration rights on this machine 

 

I hope anyone here could help me out. 

Thx so far
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
344 Views

i think u have to include ur library by hand in the makefile of your project. 

 

# List of include directories for -I compiler option (-I added when used). 

# Includes the BSP. 

ALT_INCLUDE_DIRS := "." "./src/include" "./src/include/ipv4"  

 

# List of library directories for -L linker option (-L added when used). 

# Includes the BSP. 

ALT_LIBRARY_DIRS :=
0 Kudos
Altera_Forum
Honored Contributor II
344 Views

Hi, 

thanks for your answer, but the problem is still the same. 

 

Here's the output from my console: 

/cygdrive/c/altera/91sp2/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.6/../../../../nios2-elf/bin/ld: cannot find -ltestLib.a  

 

I had these makefile changes before in APP_LIBRARY_DIRS and APP_LIBRARY_NAMES. 

Any other suggestions? 

 

Could it be a problem, that my nios stuff, like the compiler and so on is located on another partition than my project?
0 Kudos
Altera_Forum
Honored Contributor II
344 Views

Hi, 

so I have an update on my problem. For now i found a workaround which isn't nice but seems to work. 

I created the lib, name it libA, as described in the documentation, then created another library, named libB, without any c-code in it and copied the libA in. Afterwards I renamed libA to libB. 

 

Now i can include libB as a library project to my original project. I'm going to try to use this approach on another pc, where the original code for the lib isn't present.  

I'll report on any progress
0 Kudos
Altera_Forum
Honored Contributor II
344 Views

 

--- Quote Start ---  

 

I'm trying to pack parts of my NIOS-Code as a library 

All I have to do is described on Page 25. 

 

The creating part of the library is working very well,/QUOTE] 

 

I too wish to pack some of my c functions as a library. 

I have tried various approaches, based on p 2-25, and get empty archives (using V12.0sp2) 

It does not seem to be compiling the c to .o ..... 

 

Any suggestions ? 

 

I have created a library by hand editing a makefile, 

and now of course want to link it to a small function. 

All my attempts to get DE1 runnable code have failed - any suggestions ? 

 

cheers, 

Beau
0 Kudos
Altera_Forum
Honored Contributor II
344 Views

OK,  

The secret seems to be as follows : 

1) Use Eclipse to edit the Makefile - that way you will get the right copy. 

2) create a directory lib and put the library libaplc.a into it, then  

set : ALT_LIBRARY_DIRS := lib 

3) set : ALT_LIBRARY_NAMES := aplc 

4) set : ALT_LDDEPS := D:\home\jbww\Design\Altera\Eclipse_v12\NiosProjects\aplc_matrix\lib\libaplc.a 

 

I have had to simplify the I/O for the moment, but I can now translate Apl to c using aplc., and have it compile and run on the DE1 board : 

The same partially gutted library source compiles OK on the Altera NiosII. 

 

Here is a simple set of matrix operations in a function "matrix": 

Source in AplX: 

 

matrix 

 

'A:' 

A ← ⍳ 5 

' ' 

'B:' 

B ← ⍳ 9 

' ' 

'C: inner product:' 

C ← A ∘.× B 

' ' 

'T: transpose:' 

T ← ⍉ C 

' ' 

'O: outer product (matrix multiply):' 

O ← C +.× T 

' ' 

'S: solve matrix:' 

S ← C ⌹ A 

 

NiosII simple floating point soft processor, on a Terassic DE1 development board : 

 

A: 

1 2 3 4 5 

 

B: 

1 2 3 4 5 6 7 8 9 

 

C: inner product: 

1 2 3 4 5 6 7 8 9 

2 4 6 8 10 12 14 16 18 

3 6 9 12 15 18 21 24 27 

4 8 12 16 20 24 28 32 36 

5 10 15 20 25 30 35 40 45 

 

T: transpose: 

1 2 3 4 5 

2 4 6 8 10 

3 6 9 12 15 

4 8 12 16 20 

5 10 15 20 25 

6 12 18 24 30 

7 14 21 28 35 

8 16 24 32 40 

9 18 27 36 45 

 

O: outer product (matrix multiply): 

285 570 855 1140 1425 

570 1140 1710 2280 2850 

855 1710 2565 3420 4275 

1140 2280 3420 4560 5700 

1425 2850 4275 5700 7125 

 

S: solve matrix: 

1 2 3 4 5 6 7 8 9 

 

cheers, 

Beau Webber
0 Kudos
Reply