Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cl.exe (MSVC) #60

Closed
taljacob2 opened this issue Jan 18, 2023 · 3 comments · Fixed by #62
Closed

Support cl.exe (MSVC) #60

taljacob2 opened this issue Jan 18, 2023 · 3 comments · Fixed by #62
Assignees
Labels
documentation Improvements or additions to documentation github help wanted Extra attention is needed msvc Relates to Microsoft VC `cl.exe` compiler release

Comments

@taljacob2
Copy link
Owner

Although we use gcc to compile our code,
We should support Windows' cl.exe (i.e. MSVC) compiler too.

Thus, when we export the finaly static library to oop.a file, we should also export it to oop.lib file

So Windows MSVC users could use our library with:

cl.exe main.c oop.lib

See https://stackoverflow.com/a/8140514/14427765
See https://mottosso.gitbooks.io/cl-exe/content/building_a_static_library.html

@taljacob2 taljacob2 added documentation Improvements or additions to documentation help wanted Extra attention is needed github release labels Jan 18, 2023
@taljacob2 taljacob2 self-assigned this Jan 18, 2023
@taljacob2
Copy link
Owner Author

How to link a static library in MSVC

https://stackoverflow.com/a/23882710/14427765

@taljacob2 taljacob2 linked a pull request Jan 19, 2023 that will close this issue
@taljacob2
Copy link
Owner Author

taljacob2 commented Jan 20, 2023

UPDATE:

How to run with visual studio:
https://stackoverflow.com/a/4446095/14427765

To link oop.lib to cl.exe main.c, place oop.lib in the root directory of the project, and add #pragma comment(lib, "Your library name here") to your main.c source code.

For example:

#pragma comment(lib, "oop.lib")

#include <stdio.h>

#include "oop.h"

int main() {
	printf("Hello World\n");

	Object* object = ObjectConstructor("Object");
	object->addIntegerRValueMember(object, PUBLIC, FIELD, "x", 121681);
	object->toString(object);

	return 0;
}

You must place oop.lib in the root folder of the project:

image

@taljacob2
Copy link
Owner Author

@taljacob2 taljacob2 added the msvc Relates to Microsoft VC `cl.exe` compiler label Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation github help wanted Extra attention is needed msvc Relates to Microsoft VC `cl.exe` compiler release
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant