nodesnim icon indicating copy to clipboard operation
nodesnim copied to clipboard

Error: Attempting to call routine : 'Color'

Open nixfreak opened this issue 4 years ago • 9 comments

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):

  • Device: osx
  • OS: 11.6 BigSurr

Additional context Source Code: `import nodesnim

Window("Hello, World")

build:

  • Scene scene
  • Label hello: call setSizeAnchor(1, 1) call setTextAlign(0.5, 0.5, 0.5, 0.5) call setText("Hello, World") call setBackgroundColor(Color(31, 45, 62))

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

nixfreak avatar Oct 13 '21 22:10 nixfreak

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 avatar Oct 13 '21 22:10 quantimnot

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 avatar Oct 13 '21 22:10 quantimnot

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,

quantimnot avatar Oct 13 '21 22:10 quantimnot

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

I will try the patch first.

nixfreak avatar Oct 14 '21 00:10 nixfreak

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 ?

nixfreak avatar Oct 14 '21 01:10 nixfreak

that was a diff created with git diff

quantimnot avatar Oct 14 '21 01:10 quantimnot

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 avatar Oct 14 '21 01:10 nixfreak

Ok switched to 1.4.8 and it compiled just fine.

nixfreak avatar Oct 14 '21 01:10 nixfreak

After changing to stable 1.4.8 every compiles fine now.

nixfreak avatar Oct 14 '21 17:10 nixfreak