I tried Phil's solution, but the problem is somewhere else. I found out that the functions in the library don't receive their parameters in the right form. I created a new empty library, created a new function, that takes no parameters, and return 58 in a byte, it worked. But when I changed it to receive a byte, and return it, as-it-was-sent, it sends back 0. Then using the debugger, I found out that either Lazarus isn't sending the parameters correctly, or the library isn't receiving them correctly.
I don't doubt my code as much as I do lazarus, because the same library works on C++, C, and D hosts.
Any ideas what's causing this? I posted a question on Stackoverflow.com too, but no help from there yet.