2018-03-18 03:57:22

Good Evening,
I wondered if someone would answer me a question of two parts, regarding dll's.
I am trying to intigrate tcp into bgt. Don't laugh. No seriously, stop laughing. No, seriously, stop laughing. I'm serious!

In any case, The way I have figured to do this is:
*have a dll library, with a setup(address, port) funtion, a send(socket, message) function, a receive(socket) and a close(socket) function.
*use dictionaries to work some fancy magic with the dll


The only problem?
1. There is no tcp library in dll format to handle this.
and 2. I can't seem to quite compile a dll library.

This is why I am asking you wonderful people. How, exactly, do I make a dll.
I have written my tcp code in a c script, for the sake of any examples you may want to give, lets call it sockets.c, I tried compiling on ubuntu, and managed to create a dll, for obvious reasons, it didn't work when I tried it, ubuntu to windows=baaad. I've got cigwin on my system, but can't seem to quite get things to compile propperly.
Any help on this matter would be appreciated, because after nearly half a month of research, I am out of ideas.
Thanks so much, and you can stop laughing now.
Nate

Nathan Smith
Managing Director of Nathan Tech
It's not disability
It's ability!

2018-03-18 04:51:55

1 Install msys2
2 Install gcc on your msys2
3 if you want, edit your system environment variable so that you can directly use gcc on your command prompt
4 gcc -shared socket.c -o socket.dll

I don't speak as good as I write, and I don't listen as good as I speak.

2018-03-18 09:16:08

@2, this is one way to do it, but I wouldn't do it if I were you smile. Just open Visual Studio 2017 and create a DLL library from the new projects->Visual C++ templates list. And as for DLL libraries, you can either use Winsock directly, or something like Boost.Asio.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2018-03-18 10:27:28

hi,
if you are using boost.asio, make sure to code your function as c calling convension:

extern "C" void send(const char* packet, const char* message)
{
your code;
}

2018-03-19 01:15:09

Hi guys
@nyanchan thank you, that was exactly what I was looking for
@ethin I can't use vs on my machine, my hard drive is too small!
@visualstudio thanks for the advice

Nathan Smith
Managing Director of Nathan Tech
It's not disability
It's ability!