dariolah / nim-iup-examples

Nim GUI examples using IUP
20 stars 3 forks source link

How to compile #1

Closed super-tomcat closed 5 years ago

super-tomcat commented 5 years ago

hello, I tried to compile the first example in Emacs but it failed with the following message:

nim c -r --app:gui example2_1.nim nim c -r --app:gui example2_1.nim Hint: used config file 'C:\nim-0.19.2\config\nim.cfg' [Conf] Hint: system [Processing] Hint: widestrs [Processing] Hint: io [Processing] Hint: example2_1 [Processing] Hint: niup [Processing] CC: stdlib_system.nim CC: ../../../../../../C:/Users/Neil/.nimble/pkgs/niup-3.27.2/niup.nim CC: example2_1.nim Error: execution of an external compiler program 'C:\MinGW\mingw64\bin\gcc.exe -c -w -mno-ms-bitfields -IC:\nim-0.19.2\lib -I"c:\Users\Neil\Documents\Nim Files\nim-iup-examples-master" -o C:\Users\Neil\nimcache\example2_1_d_7_7_7_7_7_7C87Users7Neil7.nimble7pkgs7niup-3.277.27niup.nim.c.o C:\Users\Neil\nimcache\example2_1_d_7_7_7_7_7_7C87Users7Neil7.nimble7pkgs7niup-3.277.27niup.nim.c' failed with exit code: 1

C:\Users\Neil\nimcache\example2_1_d_7_7_7_7_7_7C87Users7Neil7.nimble7pkgs7niup-3.277.27niup.nim.c:38:10: fatal error: dlfcn.h: No such file or directory

include

      ^~~~~~~~~

compilation terminated.

dariolah commented 5 years ago

Sorry about that, haven't tested it on Windows. Error is from Linux specific code for dlopen workaround in 'niup'. Try with latest 'niup' code: 3.27.3. I've committed fix but haven't tested it.

Or you can manually remove block of code from beginning of niup.nim, between lines:

# BEGIN workaround ...
...
# END workaround
super-tomcat commented 5 years ago

Hello, I made the suggestions you said in that i removed the code between

BEGIN workaround ...

...

END workaround

And this did allow most of the examples to compile and work, however i got these errors.....

All examples 4_1 to 4_4 do not work because there is no niupext ?

simple_notepad.nim does not work because it looks for libiupimglib.dll ?

scintilla_notepad.nim does not compile because it says: (28,15) Error: type mismatch: got but expected 'clong = int32'

dariolah commented 5 years ago

'niupext' is part of 'niup' package. In same folder where you removed code should be file niupext.nim. If it is missing please upgrade/install 'niup' with nimble.

Name of dll is wrong, prefix 'lib' should be removed. You can modify niup.nim and change references from 'lib.dll' to '.dll'. In this case it should be 'iupimglib.dll'.

For scintilla_notepad you'll need to rename 'libiup_scintilla.dll' to 'iup_scintilla.dll' in niup.nim.

From first error report I see that you are using nim 0.19.2. Please upgrade to 0.20.2 and try again.

If problem persists I'll install windows dev environment and try it.

super-tomcat commented 5 years ago

Hi, first of all thanks for all the help... I am going through your last message but here are some answers for now...

  1. ignore where it says I am using Nim 0.19.2, that is just a folder name from when I first installed Nim… I always update that folder with the current Nim so I am actually using the latest version which for me is version...0.20.2

  2. You say that the latest version of niup is version 3.27.3, yet when ever I install it with Nimble (tried a few times now) I only get version 3.27.2 ?

  3. Also each time I install niup with Nimble I look in the package folder and there is:

nimblemeta.json niup.nim niup.nimble

But no niupext.nim file ?

super-tomcat commented 5 years ago

After more tests i edited these to get rid of the lib prefix on the dll's....

when defined(windows): const libiupSONAME = "iup.dll" libiupcdSONAME = "iupcd.dll" libiupcontrolsSONAME = "iupcontrols.dll" libiupglcontrolsSONAME = "iupglcontrols.dll" libiupglSONAME = "iupgl.dll" libiupimglibSONAME = "iupimglib.dll" libiupimSONAME = "iupim.dll" libiup_mglplotSONAME = "iup_mglplot.dll" libiup_plotSONAME = "iup_plot.dll" libiup_scintillaSONAME = "iup_scintilla.dll" libiuptuioSONAME = "iuptuio.dll" libiupwebSONAME = "iupweb.dll"

And simple_notepad.nim now compiles and works fine.

So its just scintilla_notepad.nim that i cannot get to compile, it stops on line 28 saying:

(28, 15) Error: type mismatch: got <int> but expected 'clong = int32'

dariolah commented 5 years ago

I've commited fix in scinetilla_notepad.nim This whole proc setMarkerMask looks redundant. Probably planned for future usage but in this case is overhead. Problem is probably in how windows and linux C compilers define long type (32 or 64 bit).

Regarding 'niup' upgrade to latest version I don't know exactly how nimble works. Manual options are:

  1. delete 'niup' folder and reinstall with nimble
  2. or download from github and overwrite contents of 'niup' folder

scinetilla_notepad.nim is in github, update it same sa niup package.

I've tested it by cross compiling on Linux with Mingw and running it with wine:

PS although examples are rewrites of official tutorial in C, code is not 100% same. I've made small changes possibly some bugs. This proc setMarkerMask is example, result of quick-n-dirty copy-paste, without analyzing it.

super-tomcat commented 5 years ago

Hello, I still only get version 3.72.2 when I install with Nimble? And that's after doing Nimble refresh and also deleting the niup folder and reinstalling.

I tried your new version scintilla_notepad.nim, which does compile but pops up a message box saying:

Error could not load: iup_scintilla.dll

This is strange because the iup_scintilla.dll is in the same folder as scintilla_notepad.nim, so why it cannot find it I don't know??

dariolah commented 5 years ago

I forgot to push git tag. Try now with nimble.

I had to copy dll-s from _/usr/lib/gcc/x8664-w64-mingw32/7.3-win32/ to local folder, where iup dll-s are:

These are part of mingw compiler and iup_scintilla.dll sepends on them.

https://stackoverflow.com/questions/6404636/libstdc-6-dll-not-found/6404637#6404637

super-tomcat commented 5 years ago

That's it, now updated to 3.72.4 via Nimble.

You still need to change:

when defined(Windows): const libiupSONAME = "iup.dll" libiupcdSONAME = "libiupcd.dll" libiupcontrolsSONAME = "libiupcontrols.dll" libiupglcontrolsSONAME = "libiupglcontrols.dll" libiupglSONAME = "libiupgl.dll" libiupimglibSONAME = "libiupimglib.dll" libiupimSONAME = "libiupim.dll" libiup_mglplotSONAME = "libiup_mglplot.dll" libiup_plotSONAME = "libiup_plot.dll" libiup_scintillaSONAME = "libiup_scintilla.dll" libiuptuioSONAME = "libiuptuio.dll" libiupwebSONAME = "libiupweb.dll"

to

when defined(Windows): const libiupSONAME = "iup.dll" libiupcdSONAME = "iupcd.dll" libiupcontrolsSONAME = "iupcontrols.dll" libiupglcontrolsSONAME = "iupglcontrols.dll" libiupglSONAME = "iupgl.dll" libiupimglibSONAME = "iupimglib.dll" libiupimSONAME = "iupim.dll" libiup_mglplotSONAME = "iup_mglplot.dll" libiup_plotSONAME = "iup_plot.dll" libiup_scintillaSONAME = "iup_scintilla.dll" libiuptuioSONAME = "iuptuio.dll" libiupwebSONAME = "iupweb.dll"

I then copied the .dlls you said to the folder with the iup dlls and scintilla_notepad.nim

And it compiles and runs 👍

dariolah commented 5 years ago

Ok, last commit should be final for this issue, 3.27.5. Had it fixed and lost it :/

Thank you :)