r-lyeh-archived / spot

:cyclone: Compact and embeddable RGBA/HSLA library that supports WEBP, JPG, progressive JPG, PNG, TGA, DDS DXT1/2/3/4/5, BMP, PSD, GIF, PVR2/3 (ETC1/PVRTC), KTX (ETC1/PVRTC), PKM (ETC1), HDR, PIC, PNM (PPM/PGM), CRN, PUG, FLIF, CCZ, EXR and vectorial SVG files (C++11)
zlib License
134 stars 36 forks source link

How to link this on Cmake? #11

Closed Dekadencee closed 7 years ago

Dekadencee commented 7 years ago

I tried to use spot on one of my proyects for convert .dds files to .jpg but I always get external simbols error on spot::color.

Any tip o idea to integrate this?

r-lyeh-archived commented 7 years ago

Are you linking against spot.cpp and spotc.c files? You need spot.hpp, spot.cpp and spotc.c files only. They're in the root project folder. Any other file is unneeded.

Dekadencee commented 7 years ago

I link spot as library, sorry my bad, now I link spot as simple files of my proyect:

FILE(GLOB SpotFiles
    deps/spot/spot.hpp
    deps/spot/spot.c
    deps/spot/spot.cpp
)

add_executable(
    MyProyect
    ${SpotFiles}
    ${MainFiles}
)

And on my code:

#include "spot.hpp"

spot::image img = spot::image(dds.string().c_str());
img.save_as_jpg(out.c_str(), 100);

But still showing linking errors(LNK2019) on my proyect :( on this functions:

I don't know what its wrong now :/ my /deps/spot/ its a submodule of master of this repo, im building this on x64.

r-lyeh-archived commented 7 years ago

Don't rename spotc.c as spot.c. Try to keep the original name and tell me if it works :) In your current setup spot.c will get converted into spot.o once compiled, but then spot.cpp as spot.o again (hence, overwriting the previous C file and missing all the whole file you previously compiled)

Dekadencee commented 7 years ago

Yes sorry, the fail its on "deps/spot/spot.c", i don't see that have a aditional "c" on his name, i renamed it to "deps/spot/spotc.c" and now the build it's fine ^^

A lot of thanks, I apreciate a lot your work, so usefull lightweight libraries for any proyect ^^

r-lyeh-archived commented 7 years ago

De nada xD