Problem including header files in a C/C++ project using Altera's Nios II IDE

Hi there!

Quick question. Is anyone using the Nios II IDE (Quartus II Software version 4.1 by Altera)? If so, I'm having difficulties in how to include certain header files, e.g. socket.h and so on when using the C/C++ editor. Is there an option, I can select which tells the IDE where to find those header files? In the installation directory of Quartus I've already spotted lot's of these .h files, problem is the IDE obviously doesn't know that :-(

A workaround that I've found is to include those files manualy in my project using File -> Import, but in a larger project where header files depend on other header files, this becomes very time consuming and therefore doesn't seem to be a very smart solution.

I've also tried right click on the root directory of the project ->

System Library Properties -> C/C++ Build -> Include Paths, and entered the path where my needed headers are located, but to no avail.

Any hints or solutions are greatly appreciated, because a site search at Altera wasn't very enlightning for me either.

regards, Chris.

Reply to
sichstre
Loading thread data ...

Hello Chris,

In Nios II version 1.01 there is an example called Simple Socket Server which includes the sockets.h header file. If you are still using Nios II version 1.0, and have not upgraded yet to Nios II version 1.01 (which is available on the Nios Forum at

formatting link
there is a networking example named ntp_client which also includes sockets.h (in ntp_client.c)

The Simple Socket Server example, included with the Nios II 1.01 distribution, includes the socket.h header file. The source file which includes socket.h is simple_socket_server.c, and uses the following syntax for the include:

#include "lwip/sockets.h"

You should be able to use the same syntax in your project. If this does not work for your project, make sure that you are creating your project under the nios2 installation directory. Try using the Nios II IDE new project creation default directory location for your new application project, which is:

\verilog \niosII_cyclone_1c20\standard\software\

where "verilog" could be "vhdl", "niosII_cyclone_1c20" refers to your Nios development board flavor (Cyclone, Stratix, etc.), and "standard" refers to the particular reference design (standard, full_featured, etc.) or other Quartus project containing a Nios II cpu.

Use the Nios II IDE to create your project based on the Simple Socket Server template via File->New Project. You can then drop in all of your source code into the new projects's source code directory (path listed above), right click on the project name in Nios II IDE and select "refresh", and all of your sources will be pulled into the Nios II IDE generated make system. This will insure that all of the application project properties and system project properties defined by the Simple Socket Server template are used, and consequently will allow inclusion of "lwip/sockets.h" to find the header file.

Best regards, Stephen

Reply to
stephen_niosII

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.