Ethosa / nodesnim

The Nim GUI/2D framework, based on OpenGL and SDL2.
https://ethosa.github.io/nodesnim/nodesnim.html
MIT License
134 stars 6 forks source link

Error: Attempting to call routine : 'Color' #32

Open nixfreak opened 2 years ago

nixfreak commented 2 years ago

Describe the bug Compile time error , trying to compile a nodesnim sample "hello, world". Compile time error:

"unifont.ttf"; this will become a compile time error in the future [CStringConv] /Users/aaronm/.nimble/pkgs/nodesnim-0.3.2/nodesnim/core/font.nim(31, 47) Error: attempting to call routine: 'Color' found sdl2.Color [type declared in /Users/.nimble/pkgs/nodesnim-0.3.2/nodesnim/thirdparty/sdl2.nim(545, 3)]

To Reproduce Steps to reproduce the behavior:

  1. compile hello.nim nim c -r hello.nim

Expected behavior File should compile and show output (gui)

Desktop (please complete the following information):

Additional context Source Code: `import nodesnim

Window("Hello, World")

build:

addMainScene(scene) windowLaunch()`

**Tree of nimble/bin*** tree ~/.nimble/bin [17:04:37] /Users/.nimble/bin ├── SDL2 ├── SDL2_image ├── SDL2_mixer ├── SDL2_ttf ├── biblioteca_guarrilla -> ../pkgs/biblioteca_guarrilla-#head/biblioteca_guarrilla ├── choosenim ├── ducere -> ../pkgs/basolato-0.10.0/basolato/cli/ducere ├── faker -> ../pkgs/faker-0.14.0/faker/cli/faker ├── inim -> ../pkgs/inim-0.6.1/inim ├── nim ├── nim-gdb ├── nimble ├── nimgrep ├── nimpretty ├── nimsuggest └── testament

quantimnot commented 2 years ago

I ran into the same problem. I use the development version of Nim. I found that I could run the example if I used 1.4.8 instead.

In fact I meant to investigate if this is a bug in the development version or not.

quantimnot commented 2 years ago

It may have something to do with symbol resolution. There is the tuple in sdl2 named Color and then there is a constructor in color named Color.

Also, I had some issues linking SDL2 on my macOS system. I have a rather old system so your mileage may vary. I ended downloading the frameworks and attaching them with:

for dmg in SDL2*.dmg; do hdiutil attach $dmg; done

I then created a config.nims file containing this:

--define:SDL_Static
{.passL: "-rpath /Volumes/SDL2".}
{.passL: "-rpath /Volumes/SDL2_image".}
{.passL: "-rpath /Volumes/SDL2_ttf".}
{.passL: "-rpath /Volumes/SDL2_mixer".}
{.passL: "-F /Volumes/SDL2".}
{.passL: "-F /Volumes/SDL2_image".}
{.passL: "-F /Volumes/SDL2_ttf".}
{.passL: "-F /Volumes/SDL2_mixer".}
{.passL: "-framework SDL2".}
{.passL: "-framework SDL2_image".}
{.passL: "-framework SDL2_ttf".}
{.passL: "-framework SDL2_mixer".}
quantimnot commented 2 years ago

This will fix the compilation error:

diff --git a/src/nodesnim/core/font.nim b/src/nodesnim/core/font.nim
index 131cff3..6c60543 100644
--- a/src/nodesnim/core/font.nim
+++ b/src/nodesnim/core/font.nim
@@ -1,7 +1,7 @@
 # author: Ethosa
-## Provides TTF text rendering. Use SDL2_ttf.
+## Provides TTF text rendering. Use SDL2_ttf
+import ../thirdparty/sdl2 except Color
 import
-  ../thirdparty/sdl2,
   ../thirdparty/sdl2/ttf,
   ../thirdparty/opengl,
nixfreak commented 2 years ago

I'm getting same issue on Bohdi Linux (Ubuntu 20.0)

I will try the patch first.

nixfreak commented 2 years ago

diff --git a/src/nodesnim/core/font.nim b/src/nodesnim/core/font.nim

I really confused are you saying create two directories a and b ? also do you mean git-diff ?

quantimnot commented 2 years ago

that was a diff created with git diff

nixfreak commented 2 years ago

Same issue using nightly also

nixfreak@cha0s-Bodhi:~/lang/nim/nodesnim/examples/calculator$ nim c -r main.nim Hint: used config file '/home/nixfreak/.choosenim/toolchains/nim-#version-1-6/config/nim.cfg' [Conf] Hint: used config file '/home/nixfreak/.choosenim/toolchains/nim-#version-1-6/config/config.nims' [Conf] Hint: used config file '/home/nixfreak/lang/nim/nodesnim/examples/calculator/nim.cfg' [Conf] ................................................................................... /home/nixfreak/lang/nim/nodesnim/src/nodesnim/thirdparty/opengl/private/errors.nim(77, 49) Warning: conversion to enum with holes is unsafe: GLerrorCode(glGetError()) [HoleEnumConv] ....................... /home/nixfreak/lang/nim/nodesnim/src/nodesnim/core/image.nim(8, 3) Warning: imported and not used: 'exceptions' [UnusedImport] ........... /home/nixfreak/lang/nim/nodesnim/src/nodesnim/core/nodes_os.nim(29, 51) Warning: implicit conversion to 'cstring' from a non-const location: parentDir((filename: "/home/nixfreak/lang/nim/nodesnim/src/nodesnim/core/nodes_os.nim", line: 29, column: 35).filename) / "unifont.ttf"; this will become a compile time error in the future [CStringConv] /home/nixfreak/lang/nim/nodesnim/src/nodesnim/core/font.nim(31, 47) Error: attempting to call routine: 'Color' found sdl2.Color [type declared in /home/nixfreak/lang/nim/nodesnim/src/nodesnim/thirdparty/sdl2.nim(545, 3)]

nixfreak commented 2 years ago

Ok switched to 1.4.8 and it compiled just fine.

nixfreak commented 2 years ago

After changing to stable 1.4.8 every compiles fine now.