Sign in to follow this  

Cant compile plugin

Recommended Posts

Posted (edited)

Hello guys, im trying to compile my first plugin ever, im a n00b @ C i learned a badic C when i was in school like 7 yeas ago. When i try to compile the plugin i get this error:

-------------- Build: Debug in hellocod (compiler: GNU GCC Compiler)---------------

mingw32-gcc.exe -Wall -DBUILD_DLL -g  -c C:\CProjects\hellocod\main.c -o obj\Debug\main.o
mingw32-g++.exe -shared -Wl,--output-def=bin\Debug\libhellocod.def -Wl,--out-implib=bin\Debug\libhellocod.a -Wl,--dll  obj\Debug\main.o  -o bin\Debug\hellocod.dll  -luser32
In file included from C:\CProjects\hellocod\main.c:21:0:
C:\CProjects\hellocod\pinc.h:86:9: note: #pragma message: Compiling a plugin using CoD4X Plugin API. Your compiler is GCC / G++, you are using C.
 #pragma message msg
obj\Debug\main.o: In function `OnInit':
C:/CProjects/hellocod/main.c:40: undefined reference to `Plugin_Printf'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

And i dont undertand why because my main.c include "pinc.h" that includes other dependencyes right? (I never worked with headers)

This is my main.c

#include "pinc.h"

PCL void OnInfoRequest(pluginInfo_t *info){	// Function used to obtain information about the plugin
    // Memory pointed by info is allocated by the server binary, just fill in the fields

    // =====  MANDATORY FIELDS  =====
    info->handlerVersion.major = PLUGIN_HANDLER_VERSION_MAJOR;
    info->handlerVersion.minor = PLUGIN_HANDLER_VERSION_MINOR;	// Requested handler version

    // =====  OPTIONAL  FIELDS  =====
    info->pluginVersion.major = 1;
    info->pluginVersion.minor = 0;	// Plugin version
    strncpy(info->fullName,"hellocod plugins", sizeof(info->fullName)); //Full plugin name
    strncpy(info->shortDescription,"Plugin that say hello",sizeof(info->shortDescription)); // Short plugin description
    strncpy(info->longDescription,"This plugin say hello to players.",sizeof(info->longDescription));

PCL int OnInit(){	// Funciton called on server initiation

    Plugin_Printf("hellocod plugin is ready to work\n");
    return 0;

Other source code file in the same folder of main.c are the headers: pinc.h callback_declarations.h declarations.h function_declarations.h plugin_declarations.h

I really need help :(

Edited by tasobro

Share this post

Link to post
Share on other sites

There is compiler and linker. Compiler cares about your header files. The linker does not. To be successful with the linker you need to point it to the files containing the unresolved symbols. 

Share this post

Link to post
Share on other sites

You are missing a file called libcom_plugin.a or you are with linking to it -Icom_plugin

File gets created when you compile cod4x server.

  • Thanks 1

Share this post

Link to post
Share on other sites

To compile server files do i need NASM 32 or 64 bit?

MinGW 32 bit right?

Share this post

Link to post
Share on other sites

Mingw-w64 but 32-bit compiler

About NASM idk but I guess both work


Share this post

Link to post
Share on other sites

Ok using mingw-w64 and NASM 64bit seems to work but something is still wrong. Inside bin folder now there are 2 files cod4x18_dedrun.exe and cod4x18_dedrun.def. cod4x18_dedrun.exe seems to work, i can start a server and join but i got an error in the terminal.

nasm obj/_collision_std.o
nasm obj/_dobj_skel.o
nasm obj/_xmodel_load_phys_collmap.o
nasm obj/_db_registry.o
nasm obj/_dobj.o
nasm obj/_com_stringtable.o
nasm obj/_cm_trace.o
gcc obj/version.o -DCOD4X18UPDATE -DOFFICIAL -DBUILD_NUMBER=986 -DBUILD_BRANCH=master -DBUILD_REVISION=b4e2e9b6087bfdf8d58c06da3f23c8ce98fb5ba1 -DWINVER=0x501
g++ bin/cod4x18_dedrun.exe
pexports bin/cod4x18_dedrun.def
/usr/bin/sh: pexports: command not found
mingw32-make: *** [makefile:245: bin/cod4x18_dedrun.def] Error 127

Tomorrow i will try to compile my plugins. Thanks for the help so far.

Share this post

Link to post
Share on other sites

You need to have pexports installed into your mingw.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this