tonis2 / stb.c3

stb bindings for C3 language
Apache License 2.0
1 stars 1 forks source link

Help on compile #1

Open LukyGuyLucky opened 7 months ago

LukyGuyLucky commented 7 months ago

I am writing for help on compile stb c3 sample on Windows 10 64 bit (VS 2019).Tring to compile

import stb; fn void main(){}

it is ok.but when trying to compile below,the compiler just complains undefined symbol: stbi_write_png but stbi_write_png is exactly in stb.c3.

Any help would be appreciated.

E:\Learning\c3pack\stb\stb.c3-main>c3c compile-run testimg.c3 stb.c3

module testimg;

import std::io; import stb;

char[*] img6x5_template = ".*." "....." ".*.." "....." ".....";

fn void image_write_test() { // make a RGB version of the template image // use red on blue to detect R<->B swaps char[653] img6x5_rgb; float[653] img6x5_rgbf; int i;

for (i = 0; i < 65; i++) { int on = (int)(img6x5_template[i] == ''); img6x5_rgb[i3 + 0] = on ? 255 : 0; img6x5_rgb[i3 + 1] = 0; img6x5_rgb[i*3 + 2] = on ? 0 : 255;

  img6x5_rgbf[i*3 + 0] = on ? 1.0f : 0.0f;
  img6x5_rgbf[i*3 + 1] = 0.0f;
  img6x5_rgbf[i*3 + 2] = on ? 0.0f : 1.0f;

}

stb::stbi_write_png("ouput/wr6x5_regular.png", 6, 5, 3, (void)&img6x5_rgb, 63); }

tonis2 commented 6 months ago

Hei @LukyGuyLucky Sorry for answering so late, didn't get notification for the issue, I haven't tried to use these stb bindings for writing images, so can't validate for sure.

But if you check the code here

Lot of code is behind some #ifdef checks, so probably in your example the compiler just ignores the code you need.

You can try enable these definition checks in your code or just manually edit the C code and remove them, I had to to the same for image read fn bindings

LukyGuyLucky commented 6 months ago

Thank you so much for the feeback.I think this is very helpful. I will try later.

Thank you and best regards, Peter