Экспортируйте все символы при создании DLL

Просто была аналогичная проблема в Eclipse, исправленная с помощью:

rightclick on project->Properties->Deployment Assembly->add Maven Dependencies

, что-то вытолкнуло это раньше, пока я редактировал мой pom.xml

У меня были все необходимые файлы jar, taglib uri и web.xml были в порядке

65
задан tzot 22 October 2008 в 12:38
поделиться

4 ответа

Это может быть сделано...

способ, которым мы делаем это здесь, состоит в том, чтобы использовать / опцию DEF компоновщика передать "файл определения модуля" содержащий список нашего экспорта. Я вижу от Вашего вопроса, что Вы знаете об этих файлах. Однако мы не делаем этого вручную. Список экспорта сам создается команда dumpbin/LINKERMEMBER и управление выводом с помощью простого сценария к формату файла определения модуля.

Это - большая работа для установки, но это позволяет нам компилировать код, созданный без dllexport объявлений для Unix в Windows.

39
ответ дан Bernard 7 November 2019 в 11:46
поделиться

Нет, Вам будет нужен макрос, который решает к __declspec(dllexport), когда он включен .cpp файлом, который реализует экспортируемые функции и решает к __declspec(dllimport) иначе.

-3
ответ дан angelsl 7 November 2019 в 11:46
поделиться

I've written a small program to parse the output of "dumpbin /linkermember" on the .lib file. I have upwards of 8,000 function references to export from one DLL.

The problem with doing it on a DLL is that you have to link the DLL without the exported definitions once to create the .lib file, then generate the .def which means you now have to relink the DLL again with the .def file to actually have the references exported.

Working with static libraries is easier. Compile all your sources into static libs, run dumbin, generate a .def with your little program, then link the libs together into a DLL now that the export names are available.

Unfortunately my company won't allow me to show you the source. The work involved is recognizing which "public symbols" in the dump output are not needed in your def file. You have to throw away a lot of those references, NULL_IMPORT_DESCRIPTOR, NULL_THUNK_DATA, __imp*, etc.

8
ответ дан user72260 24 November 2019 в 15:31
поделиться

Возможно, кто-то находит полезным мой сценарий Python для преобразования .dump к .def.

import sys, os
functions = []
startPoint = False
# Exclude standard API like sprintf to avoid multiple definition link error
excluded_functions = [ 'sprintf', 'snprintf', 'sscanf', 'fprintf' ]

if len(sys.argv) < 2:
    print('Usage: %s <Input .dump file> <Output .def file>.' % sys.argv[0])
    print('Example: %s myStaticLib.dump exports.def' % sys.argv[0])
    sys.exit(1)
print('%s: Processing %s to %s' % (sys.argv[0], sys.argv[1], sys.argv[2]))

fin = open(sys.argv[1], 'r')
lines = fin.readlines()
fin.close()

# Reading
for l in lines:
    l_str = l.strip()
    if (startPoint == True) and (l_str == 'Summary'): # end point
        break
    if (startPoint == False) and ("public symbols" in l_str):
        startPoint = True
        continue
    if (startPoint == True) and l_str is not '':
        funcName = l_str.split(' ')[-1]
        if funcName not in excluded_functions:
            functions.append("    " + funcName)
# Writing
fout = open(sys.argv[2], 'w')
fout.write('EXPORTS\n')
for f in functions:
    fout.write('%s\n' % f)
fout.close()

С этим сценарием можно получить .def файл для .lib на двух шагах:

dumpbin /LINKERMEMBER:1 myStaticLib.lib > myExports.dump
python dump2def.py myExports.dump myExports.def
0
ответ дан 24 November 2019 в 15:31
поделиться
Другие вопросы по тегам:

Похожие вопросы: