Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

nano-x user program

Hello all,

i tryed the nano-x, nanowm, nxview and i would like to write some user programs for nano-x windows.

But when i wanted to compile the program from http://www.microwindows.org/programmingintro1.html

(sample.c)

#define MWINCLUDECOLORS# include <stdio.h># include "nano-X.h"

int main(int ac,char **av)

{

GR_WINDOW_ID w;

GR_EVENT event;

if (GrOpen() < 0) {

printf("Can't open graphics\n");

exit(1);

}

w = GrNewWindow(GR_ROOT_WINDOW_ID, 20, 20, 100, 60,

4, WHITE, BLUE);

GrMapWindow(w);

for (;;) {

GrGetNextEvent(&event);

}

GrClose();

return 0;

}

---------------------------------

it finished with error that the compiler dont know the "nano-X.h" and it is true, in ...nios2/toolchain-build/build/nios2/include is not exist.

I tryed to copy from /user/microwin/src/include, but this header need some next headers and c. source code.

How is possible to use nano-x api for user programming ? Could you advice me ? I was surprised and i would like to try it :)

Thank you for your answer.

Jan Naceradsky, Czech republic

9 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I included the program in the uiCLinux/user/ directory tree and did the necessary settings to have it shown in "make menuconfig" (see the Wiki on how to do this.)

    I successfully used this Makefile:

    # Makefile for displaytext application

    EXEC = displaytext

    OBJS = $(EXEC).o

    SOURCE = $(EXEC).c# LIBADD = -L $(STAGEDIR)/usr/lib

    INCLUDEDIRS = -I $(STAGEDIR)/usr/include/microwin

    LDLIBS += -l nano-X

    LDLIBS += -l pthread

    all: $(EXEC)

    # $(EXEC): $(OBJS)

    $(EXEC):

    @echo ------ "@:" $@

    @echo ------ INCLUDEDIRS: $(INCLUDEDIRS)

    @echo ------ EXEC: $(EXEC)

    @echo ------ OBJS: $(OBJS)

    @echo ------ LDFLAGS: $(LDFLAGS)

    @echo ------ LDLIBS: $(LDLIBS)

    @echo ------ CC: $(CC)

    @echo ------ LIBADD: $(LIBADD)

    @echo ------ STAGEDIR: $(STAGEDIR)

    $(CC) $(LDFLAGS) -o $@ $(SOURCE) $(INCLUDEDIRS) $(LIBADD) $(LDLIBS)

    romfs:

    $(ROMFSINST) /usr/bin/$(EXEC)

    clean:

    -rm -f $(EXEC) *.elf *.gdb *.o

    -Michael
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hello,

    thank you for reply, but i am not just familier with make file etc... so i tryed to change some source code in /user/microwin/src/demos/nanox for example i copy the tutorial sample to demo.c and run MAKE,

    but the demo in romfs/bin was the same ... i found that demo is in

    microwin/src/bin and obj file in

    microwin/src/obj

    and the final file in romfs/bin is the same.

    How can i force to make again demo from demo.c ? (or any other file - demo2.c, dashdemo.c etc. -

    when i set

    [*] other demo in menuconfig, i can test in niosII embedded evaluation kit and they run okay :)) )

    Thank you very much.

    Jan
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Michael,

    i tryed your way ... make new directory /user/displaytext, created displaytext.c and insert to makefile in /user and to Kconfig new lines according to description for add new user application

    and use your makefile, but no object file displaytext.o and no displaytext for running in uclinux was created.

    For me it was be best to change only for example demo2.c and it compile and use in my application.

    How can i compile only one file with gcc in /user/microwin/src/demos/nanox/demo2.c ?

    Thankyou.

    Jan
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I supose "user" is located within your ucLinux-dist directory (besides vendors) and the "Makefile" is in uClinux-dist/user/microwin/src/demos/nanox

    AFAIR: if the make system is set up correctly:

    "make user/microwin/src/demos/nanox"

    -Michael
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    it looks very simple, but it works for example for cpu

    />make user/cpu/cpu

    it compile cpu okay, but

    />make user/microwin/src/demos/nanox

    make:Nothing to be done for 'user/microwin/src/demos/nanox'.

    />make user/microwin/src/demos/nanowm

    make:Nothing to be done for 'user/microwin/src/demos/nanowm'.

    />make user/microwin/src/demos/nanox/demo2

    nano-X.h: No such file or directory

    error ......

    .....

    Make: Error1

    I would need to run or create makefile, where would be set directories well or how to run the all compilation again :(.

    Could you advise me ?

    Thank you.

    Jan
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You do need to create an appropriate Makefile. I did post an example. More examples can be found in the very many subdirectories of "user".

    For my app I created a directory right below user copntaining the source code and the Makefile.

    I updated the main make configuration to make this director<y knwn to include this directory and show it in menuconfig.

    Of course you need to have the make system create the nono-X libs by checking the appropriate options with menuconfig.

    -Michael
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    finally I created user/displaytext and added it in menuconfig, i run compiler in this directory:

    />nios2-linux-uclibc-gcc displaytext.c -o displaytext -I/home/uclinux/nios2-linux/uClinux-dist/user/microwin/src/include -L/home/uclinux/nios2-linux/uClinux-dist/user/microwin/src/lib -lnano-X -lpthread

    and it compiled okay to file for running

    *displaytext

    but when i run in altera nios ii embedded evaluation kit (http://www.terasic.com.tw/cgi-bin/page/archive.pl?language=english&categoryno=56&no=372) after

    />nano-X &

    />nanowm &

    />displaytext &

    it made crash system - uclinux finished and i am back from nios-terminal.

    When i see to make process, i see that make run nios2-linux-uclibc-gcc .....with -lmwengine -lmwdrivers -lmwfonts -ljpeg -lpthread -lm -lz

    and when i try:

    />nios2-linux-uclibc-gcc displaytext.c -o displaytext -I/home/uclinux/nios2-linux/uClinux-dist/user/microwin/src/include -L/home/uclinux/nios2-linux/uClinux-dist/user/microwin/src/lib -lmwengine -lmwdrivers -lmwfonts -lphtread -lm -lz

    It reports:

    /home/uclinux/nios2-linux/toolchain-build/build/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/bin/ld.real: cannot find -lphtread

    collect2: ld returned 1 exit status

    Now i am not able to continue. I tryed to make all again with this error.

    I compiled user/microwin/demos first time only random way, i think.

    Maybe i with make clean and make erase something important.

    I can try again install uclinux and compile again.

    I wanted only use nano-x with nxview example.jpg

    and after this draw and erase some lines in real time.....

    Is any other way to draw/erase lines except use nano-x (lib) ?

    Thank you.

    Jan

    I tryed this links, but it doesnt exist:

    http://www.nioswiki.com/operatingsystems/uclinux/framebuffer

    -------------------------------- doesnt exist: --------------------

    drunken79 (http://forum.niosforum.com/forum/index.php?showuser=6042) posted SDL sources at sdl for nios2 (http://drunken.inter****.com/sdl.tar.gz)

    look in the file CONFIGURE.NIOS for ./configure options. After compiling, the library is in /src/.libs/ or in the directory you specified with --prefix.

    Some small example programms from :

    example sdl programms (http://drunken.inter****.com/examples.tar.gz)

    And a thread at gmane about uclinux and libsdl :

    gmane sdl on uclinux (http://comments.gmane.org/gmane.comp.lib.sdl/4795)
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    It reports:

    /home/uclinux/nios2-linux/toolchain-build/build/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/bin/ld.real: cannot find -lphtread

    --- Quote End ---

    If you need a threadded application you can activate the pthread support in menuconfig and/or define your application in the config files to be depending not only on nano-x, but on pthreadlib, too.

    --- Quote Start ---

    Is any other way to draw/erase lines except use nano-x (lib) ?

    --- Quote End ---

    (nano-) X is the Linux way to use a graphical display. Everything else would be very non-standard and thus not supported by anybody..

    --- Quote Start ---

    I tryed this links, but it doesnt exist:

    http://www.nioswiki.com/operatingsys...ux/framebuffer (http://www.nioswiki.com/operatingsystems/uclinux/framebuffer)

    --- Quote End ---

    No problem here.

    -Michael
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I thought these links:-)

    -------------------------------- doesnt exist: --------------------

    drunken79 (http://forum.niosforum.com/forum/index.php?showuser=6042) posted SDL sources at sdl for nios2 (http://drunken.inter****.com/sdl.tar.gz)

    look in the file CONFIGURE.NIOS for ./configure options. After compiling, the library is in /src/.libs/ or in the directory you specified with --prefix.

    Some small example programms from :

    example sdl programms (http://drunken.inter****.com/examples.tar.gz)

    And a thread at gmane about uclinux and libsdl :

    gmane sdl on uclinux (http://comments.gmane.org/gmane.comp.lib.sdl/4795)

    -------------------------------

    Jan