vusalg
@vusalg
Студент программист, второй курс

Создание динамической библиотеки?

Надо создать динамическую библиотеку. В среде разработки все работает. При сборке руками что то упускаю (догадываюсь что, но как исправить не нагуглил).

Вот мои действия:

g++ -std=c++11 -fPIC -c mygl.cpp
g++ -shared -o libmygl.so mygl.o
g++ -std=c++11 -fPIC -c main.cpp
g++ main.o -L. -lmygl -o result


Результат:
main.o: In function `main':
main.cpp:(.text+0x1d): undefined reference to `SDL_Init'
main.cpp:(.text+0x4b): undefined reference to `SDL_GL_SetAttribute'
main.cpp:(.text+0x5a): undefined reference to `SDL_GL_SetAttribute'
main.cpp:(.text+0x69): undefined reference to `SDL_GL_SetAttribute'
main.cpp:(.text+0x78): undefined reference to `SDL_GL_SetAttribute'
main.cpp:(.text+0x87): undefined reference to `SDL_GL_SetAttribute'
main.o:main.cpp:(.text+0x96): more undefined references to `SDL_GL_SetAttribute' follow
main.o: In function `main':
main.cpp:(.text+0xdb): undefined reference to `SDL_CreateWindow'
main.cpp:(.text+0x127): undefined reference to `SDL_GL_CreateContext'
main.cpp:(.text+0x183): undefined reference to `SDL_PollEvent'
main.cpp:(.text+0x1bf): undefined reference to `SDL_GL_SwapWindow'
main.cpp:(.text+0x1cc): undefined reference to `SDL_GetModState'
main.cpp:(.text+0x1f7): undefined reference to `SDL_GL_DeleteContext'
main.cpp:(.text+0x203): undefined reference to `SDL_DestroyWindow'
main.cpp:(.text+0x20d): undefined reference to `SDL_Quit'
./libmygl.so: undefined reference to `SDL_GL_LoadLibrary'
./libmygl.so: undefined reference to `SDL_GL_GetProcAddress'
./libmygl.so: undefined reference to `SDL_GL_UnloadLibrary'
collect2: error: ld returned 1 exit status
  • Вопрос задан
  • 580 просмотров
Решения вопроса 1
@akileev
Java / Scala developer
У вас программа и динамическая библиотека не слинкованы с библиотекой SDL.

g++ -shared -o libmygl.so -std=c++11 -fPIC -c mygl.cpp -lsdl
g++ -o result -std=c++11 -L. -fPIC -c main.cpp -lsdl -lmygl
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы