Error: 'main' is normally a non-static function [-Werror=main] int main(int argc, char * const argv[])

hi
I am using libcurl RTSP code from libcurl example - rtsp.c,
but during the built program in Dveloper studio.I’m getting error like this

make: Warning: File ‘Makefile’ has modification time 0.37 s in the future
make: Entering directory ‘D:\likhith\RTSP_4g\rtsp4g\mai/Target_Legato_Debug’
cd …;mkapp -t wp76xx -o /tmp/build/mai/Target_Legato_Debug -w /tmp/build/mai/Target_Legato_Debug -i “/legato/interfaces/portService” -i “/legato/interfaces/watchdog” -i “/legato/interfaces/atServices” -i “/legato/interfaces/supervisor” -i “/legato/interfaces/secureStorage” -i “/legato/interfaces/logDaemon” -i “/legato/interfaces/positioning” -i “/legato/interfaces/wifi” -i “/legato/interfaces” -i “/legato/interfaces/airVantage/legacy” -i “/legato/interfaces/airVantage” -i “/legato/interfaces/modemServices” -s “/legato/components/dataConnectionService/platformAdaptor/default” -s “/legato/components/test/watchdogChain” -s “/legato/apps/platformServices/airVantageConnector” -s “/legato/components/airVantage” -s “/legato/modules/WiFi/apps/tools/wifi” -s “/legato/components/positioning” -s “/legato/components/secStore” -s “/legato/components/uartMode/platformAdaptor/default” -s “/legato/components/portService” -s “/legato/components/modemServices/platformAdaptor/default” -s “/legato/components/audio/platformAdaptor/default” -s “/legato/apps/tools” -s “/legato/components/3rdParty” -s “/legato/components/fwupdate/platformAdaptor/default” -s “.” -s “/legato/modules/WiFi/service” -s “/legato/components/dataConnectionService” -s “/legato/components/airVantage/platformAdaptor/default” -s “/legato/components/fwupdate” -s “/legato/components/positioning/platformAdaptor/default” -s “/legato/components/devMode” -s “/legato/components/secStore/platformAdaptor/default” -s “/legato/apps/platformServices/mqttClient” -s “/legato/components/modemServices” -s “/legato/components/atServices” -s “/legato/components/uartMode” -s “/legato/components” -C -g -X -g -L -g mai.adef
[1/7] Compiling C source
make: *** [target] Error 1
FAILED: /opt/swi/SWI9X07Y_02.28.03.01/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/opt/swi/SWI9X07Y_02.28.03.01/sysroots/armv7a-neon-poky-linux-gnueabi -MMD -MF /tmp/build/mai/Target_Legato_Debug/component/f26c1308405c201ed53ad8b9b0ed1240/obj/cdcf51cf286a67967a7396cefb781e65.o.d -c D:\likhith\RTSP_4g\rtsp4g\mai/httpGetComponent/ngm.c -o /tmp/build/mai/Target_Legato_Debug/component/f26c1308405c201ed53ad8b9b0ed1240/obj/cdcf51cf286a67967a7396cefb781e65.o -DLE_FILENAME=basename D:\likhith\RTSP_4g\rtsp4g\mai/httpGetComponent/ngm.c -Wall -fPIC -Werror -fvisibility=hidden -DMK_TOOLS_BUILD -DLEGATO_EMBEDDED -g -I /tmp/build/mai/Target_Legato_Debug -I/legato/interfaces -I/legato/framework/include -I/legato/build/wp76xx/framework/include -I/legato/interfaces/portService -I/legato/interfaces/watchdog -I/legato/interfaces/atServices -I/legato/interfaces/supervisor -I/legato/interfaces/secureStorage -I/legato/interfaces/logDaemon -I/legato/interfaces/positioning -I/legato/interfaces/wifi -I/legato/interfaces -I/legato/interfaces/airVantage/legacy -I/legato/interfaces/airVantage -I/legato/interfaces/modemServices -ID:\likhith\RTSP_4g\rtsp4g\mai -I/tmp/build/mai/Target_Legato_Debug/component/f26c1308405c201ed53ad8b9b0ed1240/src -I/tmp/build/mai/Target_Legato_Debug/api/f970c0d0e5995056740616162db61084/client -I/tmp/build/mai/Target_Legato_Debug/api/2bd7bffddfad9e92ccdb60e8b27e0f60/client -I/tmp/build/mai/Target_Legato_Debug/api/09ab5603cb04a2dc4d06607fb4ef8b75/client -DLE_COMPONENT_NAME=httpGetComponent -DLE_LOG_SESSION=httpGetComponent_LogSession -DLE_LOG_LEVEL_FILTER_PTR=httpGetComponent_LogLevelFilterPtr “-DCOMPONENT_INIT=LE_CI_LINKAGE LE_SHARED void _httpGetComponent_COMPONENT_INIT()”
D:\likhith\RTSP_4g\rtsp4g\mai/httpGetComponent/ngm.c: In function ‘_httpGetComponent_COMPONENT_INIT’:
D:\likhith\RTSP_4g\rtsp4g\mai/httpGetComponent/ngm.c:175:7: error: ‘main’ is normally a non-static function [-Werror=main]
int main(int argc, char * const argv)
^~~~
D:\likhith\RTSP_4g\rtsp4g\mai/httpGetComponent/ngm.c:285:2: error: expected declaration or statement at end of input
}
^
At top level:
D:\likhith\RTSP_4g\rtsp4g\mai/httpGetComponent/ngm.c:175:7: error: ‘main’ defined but not used [-Werror=unused-function]
int main(int argc, char * const argv)
^~~~
cc1: all warnings being treated as errors
ninja: build stopped: subcommand failed.
Makefile:37: recipe for target ‘target’ failed
make: Leaving directory ‘D:\likhith\RTSP_4g\rtsp4g\mai/Target_Legato_Debug’

how to slove this problem
ngm.c (7.8 KB)

No idea what you are writing, the syntax is totally wrong for c programming.

COMPONENT_INIT
{
int main(int argc, char * const argv)
{

Hi @likhi,

Are you wanting to pass arguments to your program?

If so, and your program is built as a Legato application, you shouldn’t call main directly - it is essentially what COMPONENT_INIT does for you automatically.

Instead, you should use the Command Line Arguments API provided by the Legato Application Framework.

Additionally, if the program is to run from the command-line, I.E., a command-line tool, you’ll need to build your own System and add a Command for it.

If you’re bulding with Developer Studio and are curious about COMPONENT_INIT, check the build output of a Legato application. Look for the _main.c file located in the project directory somewhere like: ../{myApp}/Target_Legato_Debug/app/{myApp}/src/{myApp}/.

You’ll notice the main function is generated for you:

File: _main.c

int main(int argc, const char* argv[])
{
    // Pass the args to the Command Line Arguments API.
    le_arg_SetArgs((size_t)argc, argv);
    // Make stdout line buffered so printf shows up in logs without flushing.
    setlinebuf(stdout);

   //...
}

Hope this helps.