Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Hello NAG using C

 

Hello NAG using C is a Hello World program to test the NAG library.

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: CppHelloNagC.pro

 

QT       -= core
QT       -= gui

INCLUDEPATH += /opt/NAG/cll3a09dgl/include

LIBS += -L/opt/NAG/cll3a09dgl/lib -lnagc_nag

#opt/NAG/cll3a09dgl/lib/libnagc_nag.so:-1: error: undefined reference to `sqrt'
QMAKE_LFLAGS += -lm
LIBS += -lm

#Compile with GNU C compiler
QMAKE_CXX = gcc
QMAKE_CXXFLAGS = -x c

CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app
SOURCES += main.cpp

 

 

 

 

 

main.cpp

 

#include <math.h>
#include <nag.h>
#include <nag_stdlib.h>

int main(void)
{
  char * s = 0;
  s = NAG_ALLOC(11,char);
  if (!s)
  {
    printf("Cannot allocate memory for s");
    return 1;
  }
  sprintf(s, "Hello NAG");
  puts(s);
  NAG_FREE(s);
  return 0;
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml